【问题标题】:react-native-firebase - App Crash after Push Notification Received (Android)react-native-firebase - 收到推送通知后应用程序崩溃(Android)
【发布时间】:2018-09-19 01:29:02
【问题描述】:

我有一个 NodeJS 服务器,当我的 React Native 应用程序收到来自服务器的推送通知时,应用程序停止工作。

Emulator 中,应用程序刚刚关闭,在带有 Release APK 的手机中,应用程序关闭并显示一条警告,说明应用程序停止工作。

在这里我可以展示我在我的 Android 应用程序中添加的一些配置

android/build.gradle

classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1'

build.gradle

implementation project(':react-native-firebase')
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'

通知监听器

export const configureMessaging = async () => {
  try {
    const enabled = await FirebaseMessaging.hasPermission();
    log('Push Notifications enabled?', enabled);
    return enabled;
  } catch (err) {
    return false;
  }
}; // This is returning true

export const configureOnNotificationDisplayed = () => FirebaseNotifications.onNotificationDisplayed((notification) => {
  // Process your notification as required
  // ANDROID: Remote notifications do not contain the channel ID.
  // You will have to specify this manually if you'd like to re-display the notification.
  console.log(notification);
});

export const configureOnNotification = () => FirebaseNotifications.onNotification((notification) => {
  // Process your notification as required
  console.log(notification);
});

export const configureOnNotificationOpened = () => FirebaseNotifications.onNotificationOpened((notificationOpen) => {
  // Get the action triggered by the notification being opened
  // Get information about the notification that was opened
  console.log(notification);
});

我在 AVM 中附加了一个调试器,没有抛出任何错误

连接到目标VM,地址:'localhost:8624',传输: '插座'

与目标VM断开连接,地址:'localhost:8624', 传输:“套接字”

注意

我不知道在 iOS 中发生了什么,因为应用程序没有配置 使用iOS

【问题讨论】:

  • 检查 Android Studio 日志,看看是否能找到应用崩溃的原因。我猜你需要启用权限
  • 添加一些有用的东西,你给的配置对其他人来说只是通用的
  • @AngusTay 我正在收听加载程序组件中的通知
  • @MikeM 连接到目标虚拟机,地址:'localhost:8624',传输:'socket' 与目标虚拟机断开连接,地址:'localhost:8624',传输:'socket'被抛出

标签: android firebase react-native react-native-android react-native-firebase


【解决方案1】:

问题是我有另一个使用推送通知的依赖项。我删除了它,一切正常

【讨论】:

  • 另一个依赖是什么?
猜你喜欢
  • 1970-01-01
  • 2021-01-19
  • 1970-01-01
  • 1970-01-01
  • 2021-06-10
  • 1970-01-01
  • 2014-06-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多