katzer / cordova-plugin-local-notifications

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

Local Notification is not formed in ios11 #1662

Open soniabehal opened 6 years ago

soniabehal commented 6 years ago

Local notification is not formed in ios 11 with 0.8.5 and 0.9.0-beta.3 versions . Application is able to receive the FCM(Firebase cloud messaging) notification data and when the application tries to create local notification ,its not formed even in the FCM trigger block as well as outside its scope.

Environment

Expected Behavior

Its expected that whenever the application tries to schedule the local notification ,it should appear on user's screen.

Actual Behavior

Local notification is never formed.

Steps to Reproduce

Reproduce this issue; include code to reproduce, if relevant

  1. Get the FCM token for the app
  2. Write the local notification code inside the onNotification block
  3. create the local notification on the main page even.

Context

Was trying to use the firebase cloud messaging service in ios and fcm is working fine but whenever the application tried to show user a notification ,its unable to do the same.

Tawpie commented 6 years ago

If you could post the code you're using to schedule the notification, it will help. Otherwise it's not really possible for others to assist you.

jtheiss commented 6 years ago

Maybe it is the same mistake i made first: i forgot "foreground: true" and the notification was not displayed on iOS (on Android it worked without this option)

soniabehal commented 6 years ago

@jtheiss for foreground:true, it gives me this error Argument of type '{ id: number; text: any; title: any; foreground: boolean; }' is not assignable to parameter of type 'ILocalNotification | ILocalNotification[]'. Object literal may only specify known properties, and 'foreground' does not exist in type 'ILocalNotification | ILocalNotification[]'. (property) foreground: boolean

soniabehal commented 6 years ago

@Tawpie, The code i am using to schedule the local notification is as below

this.localNotifications.schedule({
              id: ++this.id,
              text: data.extra_information,
              title: data.title
            });

and the above code is written under

this.fcm.onNotification().subscribe(data => {}) // FCM Block

There is one another issue, the local notification calls this FCM block rather then displaying to user

jtheiss commented 6 years ago

if i use the plugin like the documentation recommends it works just fine

cordova.plugins.notification.local.schedule({ title: 'My first notification', text: 'Thats pretty easy...', foreground: true });

if i use only text & title the notification is only shown on android

cordova.plugins.notification.local.schedule({ title: 'My first notification', text: 'Thats pretty easy...' });

i made the mistake during updating to 0.9 from an older version. but maybe you have a different problem... sorry i couldn't help

Tawpie commented 6 years ago

@soniabehal I would recommend including an 'at' property so the notification is provided with a time to appear. This time-to-appear should be a few seconds in the future. iOS in particular will not present a notification that was supposed to appear in the past. Some (most?) versions of Android will post stale notifications but I'd rather schedule them in the future so I don't have to worry about them being suppressed by the operating system.

MASP3000 commented 6 years ago

I think that for iOS local Notifications plugin catches the FCM Notifications when the app is in foreground.

soniabehal commented 6 years ago

@Tawpie for the "at" property, i am getting the error Argument of type '{ id: number; text: string; title: string; priority: number; at: any; }' is not assignable to parameter of type 'ILocalNotification | ILocalNotification[]'. Object literal may only specify known properties, and 'at' does not exist in type 'ILocalNotification | ILocalNotification[]'. (property) at: any

On Tue, Aug 21, 2018 at 7:32 PM Tawpie notifications@github.com wrote:

@soniabehal https://github.com/soniabehal I would recommend including an 'at' property so the notification is provided with a time to appear. This time-to-appear should be a few seconds in the future. iOS in particular will not present a notification that was supposed to appear in the past. Some (most?) versions of Android will post stale notifications but I'd rather schedule them in the future so I don't have to worry about them being suppressed by the operating system.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/katzer/cordova-plugin-local-notifications/issues/1662#issuecomment-414684864, or mute the thread https://github.com/notifications/unsubscribe-auth/AQLCqrWzXxPXbpG6SQy8ZxvAojY-lCQVks5uTBMOgaJpZM4V_l6A .

soniabehal commented 6 years ago

@MiguelSyll i am getting the opposite result. For my application, its FCM Notifications that catches the iOS local Notifications

On Wed, Aug 29, 2018 at 3:21 PM MiguelSyll notifications@github.com wrote:

I think that for iOS local Notifications plugin catches the FCM Notifications when the app is in foreground.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/katzer/cordova-plugin-local-notifications/issues/1662#issuecomment-416894793, or mute the thread https://github.com/notifications/unsubscribe-auth/AQLCqqrVzUS1qkXQuZNLy8-TM_yMbAkyks5uVmQ1gaJpZM4V_l6A .

soniabehal commented 6 years ago

@Tawpie for the simple local notification with FCM notification scope, the logs say that application has received the push notification. My code there is this.localNotifications.schedule({ id: 1, text: "Hello ios", title: "i am here", priority: 1 });

and logs are:- [Log] Received push notification (cordova.js, line 1731) [Log] {smallIcon: "res://icon", title: "i am here", defaults: 0, vibrate: false, progressBar: {enabled: false, value: 0}, …} (cordova.js, line 1731)

But the notification is not formed.

On Fri, Aug 31, 2018 at 10:16 AM sonia behal soniabehal19@gmail.com wrote:

@MiguelSyll i am getting the opposite result. For my application, its FCM Notifications that catches the iOS local Notifications

On Wed, Aug 29, 2018 at 3:21 PM MiguelSyll notifications@github.com wrote:

I think that for iOS local Notifications plugin catches the FCM Notifications when the app is in foreground.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/katzer/cordova-plugin-local-notifications/issues/1662#issuecomment-416894793, or mute the thread https://github.com/notifications/unsubscribe-auth/AQLCqqrVzUS1qkXQuZNLy8-TM_yMbAkyks5uVmQ1gaJpZM4V_l6A .

JuanCarlosSC commented 5 years ago

It happens to me exactly the same when I receive a notification from FCM and I'm in the foreground the method catches

vm.fcm.onNotification().subscribe(data => {
        if(data.wasTapped){
          console.log("Received in background");
        } else {
          console.log("Received in foreground");
          console.log("Received in foreground",JSON.stringify(data))
          vm.localNotifications.schedule({
            id: 1,
            text: 'Single ILocalNotification 1',
            sound: "default",
            foreground: true,
            data: { secret: 1 }
          });
        };
      });

That is when we call the local notification, but there is no sample, in addition to the local notification, we call the complete function of FCM and create an infinite loop, when we leave the application, we ask them to respond.