question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass data to localNotifcation and receive it in onNotification event

See original GitHub issue

Hey there!

I am trying to pass data to a localNotifcation and receive it in onNotification when i have clicked on it:

My code at presents:

     PushNotification.localPushNotification({
        title  : 'Title',
        message: 'Message',
        data   : {
            venueName: venue.name,
            venueType: venue['@type'],
            venueId  : venue['@id'],
            type     : 'venue'
        }
    });


    PushNotification.configure({
        // (optional) Called when Token is generated (iOS and Android)
        onRegister: function (token) {
            console.log('NOTIFICATIONTOKEN:', token.token);
            Helper.registerDevice(token.token);
        },

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

                const {dispatch, User} = context.props;
                let type = notification.type;

                if (notification.userInteraction) {
                    switch (notification.type) {
                        case 'venue':
                            alert('Go to Venue View')
                            break;
                    }
                }
        },

        popInitialNotification: true
    });

I can pass the data to my localNotifcation, but when i have clicked on the PushNoti, and debugging onNotification, then there is no data. Simply this is what i get:

screen shot 2016-08-11 at 13 55 46

Any ideas?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
varungupta85commented, Aug 11, 2016

@BigPun86 Can you try showing the notification like this and check if you get the data in the notification. Essentially, don’t wrap it in data

PushNotification.localPushNotification({
    title  : 'Title',
    message: 'Message',
    venueName: venue.name,
    venueType: venue['@type'],
    venueId  : venue['@id'],
    type     : 'venue'
});

I am using it this way and I am able to get the data in notification handler.

1reaction
BigPun86commented, Dec 26, 2016

@mcmatan It was an Android issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to pass data to push notification with react native
How can I pass my pushMessage(chat) into the notification? I have this onNotification and PushNotificationIOS error when received push message ...
Read more >
Local Notifications In Flutter. Notify Your Users - Medium
Notifications are an excellent way to engage your users to go back to your application or to make them to pay attention to...
Read more >
Receive messages in a JavaScript client - Firebase - Google
In order to receive the onMessage event, your app must define the Firebase messaging service worker in firebase-messaging-sw.js .
Read more >
How to Set Up Local Notifications in Flutter - freeCodeCamp
Notifications are an excellent way to engage your users or to get them to go back to your application. You can also use...
Read more >
flutter_local_notifications | Flutter Package - Pub.dev
A cross platform plugin for displaying and scheduling local notifications for ... Getting details on if the app was launched via a notification...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found