IONIC push notification not triggered when in foreground iOS

Hello @neeraj,

The Push Notifications are working in foreground, background and even in the killed state for Android and iOS both. The problem here is that localNotifications.schedule is not getting called in the foreground (only in iOS) for some reason and that is why it is not showing the notification.

If you are getting the data in the Javascript callback, it means the CometChat Push Notification Extension is working fine.

Also, after spending some time going through LocalNotifications GitHub Issues I found an open issue of local notification not working in iOS when the app is in the foreground. I am sharing the link with you so that you can post your query there and be updated on it.

Local Notification GitHub Issue:

Hope this helps

1 Like

Can you tell me how is this working in IONIC?
For ionic I am using the following push plugin to receive notifications from FCM -
For other notifications sent to me from my app server trigger this on Android and iOS.
For iOS, we send 1 additional parameter has - content_available : true in the payload, then it detects
foreground notification as well. So I am assuming cometchat needs to have this parameter too.
Because chat notifications work fine in android - foreground and background.
on iOS, background works fine, foreground doesn’t trigger. For that, content_available: true is needed.

this.pushObject.on('notification').subscribe((notification: any) => {

        // console.log('Received a notification', JSON.stringify(notification));
       The cometchat notification does not trigger "recvd a notification" log.

        alert("Received a notification"+JSON.stringify(notification));

        if (notification.additionalData.foreground == true) {

          // Schedule a single notification


            id: 1,


            text: notification.message,

            data: { secret: "key" },

            foreground: true,


        } else if (notification.additionalData.foreground == false) {

          if (notification.additionalData.type == "notification") {


          } else {

            // this.navCtrl.push("InboxPage");




Hello @neeraj,

We did a test on our ionic app. We are using FCM plugin of Ionic for Push Notification and everything seems to be working as expected.

However, after going through a few GitHub issues of Push Plugin. I found out an open issue on their GitHub. I am sharing a link to the issue below. Kindly follow this issue for updates.

Also, content_available has nothing to do with foreground push notifications.

FCM Documentation on content-available parameter:

content_available: On iOS, use this field to represent content-available in the APNs payload. When a notification or message is sent and this is set to true, an inactive client app is awoken, and the message is sent through APNs as a silent notification and not through the FCM connection server. Note that silent notifications in APNs are not guaranteed to be delivered, and can depend on factors such as the user turning on Low Power Mode, force quitting the app, etc.

iOS Documentation on content-available parameter:

To support a background update notification, make sure that the payload’s aps dictionary includes the content-available key with a value of 1

phonegap-push-plugin on content-available parameter:

First the JSON you send from APNS will need to include "content-available": 1 to the aps object. The "content-available": 1 property in your push message is a signal to iOS to wake up your app and give it up to 30 seconds of background processing

You can read about this parameter on the FCM documentation, iOS documentation and also on phonegap-push-plugin documentation.

FCM Documentation:

iOS Documentation:


I hope this helps!

1 Like

Hello @neeraj,

Can you please remove the Local Notification plugin you are using in your app?

We did test the push notification at our end with FCM plugin and Local Notification plugin in iOS, the onNotification() was not getting triggered. As soon as I removed the Local Notification plugin everything worked as expected.

Hope this helps.

I am actually using push plugin in my ionic app. So the chat notification does not trigger when the iOS app is in foreground. I can remove local notification, but even after that, the code should trigger this -
this.pushObject.on(‘notification’).subscribe((notification: any) when a foreground cometchat notification is received.
So can you recommend a solution for the push plugin? This works fine for android - foreground and background, and for ios - background works fine. Only issue is with foreground.

Hello @neeraj,

Please run your app after removing the Local Notification Cordova plugin. I am sure that this.pushObject.on(‘notification’) will be triggered in the foreground as well as in the background for both iOS and Android. The Local Notification plugin does cause an issue with all the Push Notification ionic plugin. You can check the issues section of phonegap push plugin’s GitHub repository.

Hope this helps

Hello, I tried removing local notification plugin, still the this.pushObject.on(‘notification’) did not get triggered. This issue is happening only on iOS foreground case. Otherwise it seems to be working fine.
For our app notifications, we had solved this by adding “content_available”:true and “priority”:high in the payload.
Our sample payload that works fine for iOS - background as well as foreground -

 "to" : "FCM_TOKEN",
 "notification" : {
     "body" : "Body of Your Notification",
     "title": "Title of Your Notification"
  "data" : {
     "body" : "Body of Your Notification in Data",
     "title": "Title of Your Notification in Title"

Can this be added in cometchat api? This will solve the issue.

Hi, Any update on this? Can this be fixed urgently? If that content_available change is made in the api for iOS specific notifications, this issue might be resolved.

@mayur.bhandari Kindly get back on this at as soon as possible.

Hello @neeraj,

The Push Notification payload does not require a content_available key to display Push Notification in the foreground in iOS.

With the localNotification plugin, the callbacks do not get triggered. After removing the localNotification plugin the callbacks were getting triggered as expected.

Also in the console, you can see the message object sent in the Push Notification payload. I am attaching the screenshot of the code and console log below.

We have solved it by adding this and now the foreground notifications do show up in the foreground.
So if you can add this parameter in the api, it would work.
Also, I tried your solution of removing local notifications, still the behaviour is the same.
Foreground notifications don’t trigger or show up in the app.

So how do we work around this? Can you try adding content_available parameter?

@mayur.bhandari Can you please update me on any solution for this?

@mayur.bhandari Any solution for this? If content_available can be added for iOS in Ionic framework, it should solve the issue.

Hi @mayur.bhandari Can you provide a solution for this? Or any workaround for this?

Hello @neeraj,

We have added the content_available key in the payload at our end. Please check on your end if you are getting the notification in foreground. Hope this helps

Hello @neeraj,

Can you please let us know if your push notification is working in the foreground after adding content_available key?

Just tested it, it isn’t working when the app is in foreground. It works when it is in background.
Can this exactly be done? priority: high attribute needs to added as well.

Hello @neeraj,

We have already added priority: high in the payload and everything seems to be working at our end. We cannot replicate the issue at our end.

Hello @mayur.bhandari I am not getting the notification when the iOS app is in foreground state. I have updated to the latest version of the comet chat.

This is the payload that I receive for my “user” based chat notification. This payload doesn’t contain
priority : high and content_available : true parameters as we discussed and you confirmed they have been added. Tested it today with the latest version of sdk.
Aslo, as discussed earlier - I do get notifications for background and not foreground.
This issue is for iOS platform IONIC.
Also, this is what I am using to subscribe to the user chat notifications : -

subscribeTopic() {
    let token = this.FCMToken;
    // alert("my fcm token is"+ this.FCMToken);
    CometChat.getJoinedGroups().then(groups => {
      CometChat.getAppSettings().then((settings: any) => {
        var appToken;
        settings.extensions.forEach(ext => {
          if ( == "push-notification") {
            appToken = ext.appToken;
        var userType = "user";
        var UID = this.chatID;
        var appId = this.appID;
        var region = "us";
        var topic = appId + "_" + userType + "_" + UID+ "_ios";
        var url =
          "https://push-notification-" + region + "" +
          appToken +
        fetch(url, {
          method: "POST",
          headers: new Headers({
            "Content-Type": "application/json"
          body: JSON.stringify({
            appId: appId, fcmToken: token,
            topic : topic 
          .then(response => {
            if (response.status < 200 || response.status >= 400) {
                "Error subscribing to topic: " +
                response.status +
                " - " +
            // alert('Subscribed to everything');
          .catch(error => {