问题
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