【问题标题】:Notification revived but not displayed airship React Native通知已恢复但未显示飞艇 React Native
【发布时间】:2021-11-11 15:36:40
【问题描述】:

我一直在尝试通过飞艇为我的应用获取通知。它在 iOS 上运行良好,但在 Android 上存在一些问题。

一开始,每当我发送通知说:

没有为关键 ReactNativeFirebaseMessagingHeadlessTask 注册任务

我搜索了一些答案,最后我将这些行添加到我的代码中:

messaging()
.setBackgroundMessageHandler(async (remoteMessage) => {
      console.log('Message handled in the background!', remoteMessage);
});

它现在有点用,但显示通知仍然不起作用。现在,当我收到通知时,我会从上述函数中获取此日志:

Message handled in the background!,
{
  "data": {
    "com.urbanairship.metadata": "eyJ2ZXJzaW9uX2lkIjoxLCJ0aW1lIjoxNjM2NDcxNzk3MjgyLCJwdXNoX2lkIjoiZDczN2QxZWMtNTExNC00NWI3LThhNGYtYjI1NWNmYWZiZDcxIiwiY2FtcGFpZ25zIjp7ImNhdGVnb3JpZXMiOltdfX0=",
    "com.urbanairship.push.ALERT": "Congratulations! You've successfully configured Android Push.",
    "com.urbanairship.push.APID": "26e8cdec-3e61-437c-940d-cd9e75c3a7df",
    "com.urbanairship.push.CANONICAL_PUSH_ID": "d737d1ec-5114-45b7-8a4f-b255cfafbd71",
    "com.urbanairship.push.PUSH_ID": "e51fd020-4171-11ec-a035-02423b27e6fe"
  },
  "from": "827761845713",
  "messageId": "0:1636471797306222%14a7377ff9fd7ecd",
  "sentTime": 1636471797292,
  "ttl": 2419200
}

明明收到了来自手机或平台的通知,没有任何错误(提示发送成功),但手机中仍然没有显示。

【问题讨论】:

    标签: react-native push-notification notifications android-notifications urbanairship.com


    【解决方案1】:

    问题出在 AndroidManifest.xml 文件中。 我删除了它,现在一切正常。

    <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService" android:exported="false">
      <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT" />
      </intent-filter>
    </service>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多