【问题标题】:Android onNotification never called in react-native-push-notificationAndroid onNotification 从未在 react-native-push-notification 中调用
【发布时间】:2018-12-16 17:19:23
【问题描述】:

 PushNotification.configure({
    onNotification: function(notification) {
      console.log( 'NOTIFICATION:', notification);
},
}) 

当我点击它时收到来自服务器的通知,应用程序已打开,但 onNotification 从未调用过。 我把它放在 componentDidMount() 和 App.js 中的构造函数 中,但它从未被调用过。 帮助..

【问题讨论】:

    标签: react-native push-notification react-native-android jsx react-native-push-notification


    【解决方案1】:

    您是否将所需的代码添加到 AndroidManifest.xml 中?

    例如:

    <!--more stuff above-->
    <service android:name="com.dieam.reactnativepushnotification.modules.RNPushNotificationListenerService"
      android:exported="false" >
      <intent-filter>
        <action android:name="com.google.android.c2dm.intent.RECEIVE" />
      </intent-filter>
    </service>
    

    来源:https://github.com/zo0r/react-native-push-notification

    【讨论】:

    • 切换到 react-native-firebase ..解决了所有问题
    • @3iL 从 react-native-push-notification.in 移至 react-native-firebase react-native-firebase 当通知到达后台/前台时,您将获得所有日志
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-04
    • 1970-01-01
    • 2018-02-05
    相关资源
    最近更新 更多