React-native-push-notification: onNotification method can't trig

Created on 19 Apr 2017  路  6Comments  路  Source: zo0r/react-native-push-notification

PushNotification.localNotification({
/* Android Only Properties */
id: '0', // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID
autoCancel: true, // (optional) default: true

            /* iOS and Android properties */
            title: notificationTitle,
            message: notificationText, // (required)
            actions: '["check"]',  // (Android only) See the doc for notification actions to know more
            data: data,
        });

PushNotification.configure({

    // (optional) Called when Token is generated (iOS and Android)
    onRegister: function (token) {
        alert('TOKEN:', token);
    },

    // (required) Called when a remote or local notification is opened or received
    onNotification: function (notification) {
        alert(11)
    },

    // ANDROID ONLY: GCM Sender ID (optional - not required for local notifications, but is need to receive remote push notifications)
    senderID: "YOUR GCM SENDER ID",

    permissions: {
        alert: true,
        badge: true,
        sound: true
    },
    popInitialNotification: false,

    /**
     * (optional) default: true
     * - Specified if permissions (ios) and token (android and ios) will requested or not,
     * - if not, you must call PushNotificationsHandler.requestPermissions() later
     */
    requestPermissions: true,
});
Stale

Most helpful comment

has anyone being able to make it working on Android the push notification with this library? onNotification is never called for me, I am using Firebase FCM and wrapping into ComponentDidMount all the code, onRegister is fired can get token but never able to receive push notification from remote, firebase!

Pls if you could post some code referenceS!

All 6 comments

I have the same problem

update: I fixed this by adding the right methods to my app delegate from the facebook tutorial

@mobinni can you paste the code or reference link here?

has anyone being able to make it working on Android the push notification with this library? onNotification is never called for me, I am using Firebase FCM and wrapping into ComponentDidMount all the code, onRegister is fired can get token but never able to receive push notification from remote, firebase!

Pls if you could post some code referenceS!

@lulzimfazlija have you solved it?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings