Search code examples
push-notificationreact-nativejsxreact-native-push-notification

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


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


Solution

  • 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