Android onNotification never called in react-native-push-notification

送分小仙女□ 提交于 2019-12-11 06:47:28

问题


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

notification received form the server when i clicked on it app is opened but onNotification never called. i put this in componentDidMount() and constructor in App.js but it's never called.. help..


回答1:


Did you add the required code into the AndroidManifest.xml?

For example :

<!--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>

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



来源:https://stackoverflow.com/questions/51238501/android-onnotification-never-called-in-react-native-push-notification

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!