katzer / cordova-plugin-local-notifications

Cordova Local-Notification Plugin
Apache License 2.0
2.57k stars 1.75k forks source link

notification data cannot be retrieved when app is not running in background #1393

Closed felixliu226 closed 6 years ago

felixliu226 commented 7 years ago

WARNING: IF YOU IGNORE THIS TEMPLATE, WE'LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!

Provide a general summary of the issue.

Your Environment

Expected Behavior

I use the following code to set a local notification

   setLocalNotification() {
      this.localNotifications.schedule({
        id: 1,
        title: 'Test Notification',
        text: 'Delayed ILocalNotification',
        at: new Date(new Date().getTime() + 5 * 1000),
        data: {'message': 'this is the first alert.'}
      });
    }

   env.localNotifications.on('click', (notification) => {
        console.log(notification.id);
        console.log(notification.data);
    });

I want to get the data when I enter the app. It works when the app is keep running at background, and I can see the data from log. It should also be work if we kill the app after the setup of notification.

Actual Behavior

However, after we setup the notification, if we kill the app, I can still received the notifications but cannot get the data.

Steps to Reproduce

  1. create an ionic project
  2. use the above code to set notification and log data
  3. run the app, click the button to set notification, and then kill the app
  4. the notification can be received as expected, but cannot find the data in log

Context

I tried two android devices, it's still there. And also add the platform.ready() condition before the localnotification.on('click', ...) but still not works

Debug logs

shivalipawar commented 7 years ago

I am also facing the same issue, the $rootScope.$on('$cordovaPushV5:notificationReceived', function (event, data) {} event is not called when the app is killed.

katzer commented 6 years ago

Please try out with latest master or reopen the ticket again. I cannot reproduce.