FCM: Doesnt work on iOS in foreground

Hi there,
I have a strange problem:

When i send a push notification to iOS, it only gets recieved, when the app is on background or killed.
If the app is in foreground, nothing happens at all.
On Android everything works just fine.
The strange thing is, that i have the same code running in other projects and there are no issues.

Another strange thing:
It seems like the onNotification-method is only triggered, when i recieve a notification with a killed app and tap on the notification.

Here my code:

init() {
    if (!this.storage.isApp) {
      return;
    }
    
    this.fcm.getToken().then(token => {
      alert(token);
      this.rest.post('/update/notikey', { noti_key: token }, true).then(data => { }, error => { });
    })
    console.log('subscribe On Notification');
    this.fcm.onNotification().subscribe(data => {
      alert('noti');
      console.log('noti', data);
    });
  }

Any clues would be highly appreciated.

Thank you
Skee

Which version of the plugin are you using of FCM?
Are you able to see any error in XCode logs?

Ok, i figured it out:
It looks like, there is an incompatibility between the native local-notification-plugin and, apparently, all available fcm-related plugins on recent ios versions
So, as soon as i install both, the fcm plugins stop working correctly.
cordova-plugin-fcm is still the best of all solutions, but, as i described, the app doesnt recognize push notifications in foreground, when the local notifications are installed as well.

I will raise another topic for detailed discussions on this topic.

regards
skee

1 Like

Hello Skee,

Did you find a solution for foreground notifications on IOS? I’m trying to use the local notification plugin to schedule a notification when I receive it in foreground.

Thanks!

hi buddyagent
did u find any solutions for this

I use cordova-plugin-fcm-with-dependecy-updated 2.2.5 and I receive the notification. However, if you try to schedule LocalNotification that is not going to work on IOS in foreground mode. What I did is that I just receive the notification data and show a toast message on IOS instead of scheduling a local notification.

We cannot display the notifcation in notification bar when the app is running foreground.
We will have to toast the notfication data inside the app when running foreground.