iOS app doesn't receive background push notifications from Firebase










0















I'm trying to get push notifications working in a Cordova app I'm working on. They work perfectly in the Android app and they work perfectly in the iOS app when it's in the foreground, but I don't receive any notifications when the app is in the background or terminated.



I have the "Push Notifications" and "Background Modes - Remote notifications" capabilities enabled:



xcode capabilities



And I'm 100% sure the server has the device token (since push notifications are working in the foreground, and I can see it in the database).



This is how I'm sending the push notification using the firebase-admin node module:



await firebase.messaging().send(
token: userDeviceToken,
data: foo: 'bar',
notification:
title: 'This is a notification title',
body: 'This is a notification body',
,
);


What am I missing?



EDIT:



If I launch the app or bring it to the foreground after it was supposed to receive a notification, it acts like it received an in-app notification. This happens even if I wait several minutes after the notification was sent before launching the app.










share|improve this question




























    0















    I'm trying to get push notifications working in a Cordova app I'm working on. They work perfectly in the Android app and they work perfectly in the iOS app when it's in the foreground, but I don't receive any notifications when the app is in the background or terminated.



    I have the "Push Notifications" and "Background Modes - Remote notifications" capabilities enabled:



    xcode capabilities



    And I'm 100% sure the server has the device token (since push notifications are working in the foreground, and I can see it in the database).



    This is how I'm sending the push notification using the firebase-admin node module:



    await firebase.messaging().send(
    token: userDeviceToken,
    data: foo: 'bar',
    notification:
    title: 'This is a notification title',
    body: 'This is a notification body',
    ,
    );


    What am I missing?



    EDIT:



    If I launch the app or bring it to the foreground after it was supposed to receive a notification, it acts like it received an in-app notification. This happens even if I wait several minutes after the notification was sent before launching the app.










    share|improve this question


























      0












      0








      0








      I'm trying to get push notifications working in a Cordova app I'm working on. They work perfectly in the Android app and they work perfectly in the iOS app when it's in the foreground, but I don't receive any notifications when the app is in the background or terminated.



      I have the "Push Notifications" and "Background Modes - Remote notifications" capabilities enabled:



      xcode capabilities



      And I'm 100% sure the server has the device token (since push notifications are working in the foreground, and I can see it in the database).



      This is how I'm sending the push notification using the firebase-admin node module:



      await firebase.messaging().send(
      token: userDeviceToken,
      data: foo: 'bar',
      notification:
      title: 'This is a notification title',
      body: 'This is a notification body',
      ,
      );


      What am I missing?



      EDIT:



      If I launch the app or bring it to the foreground after it was supposed to receive a notification, it acts like it received an in-app notification. This happens even if I wait several minutes after the notification was sent before launching the app.










      share|improve this question
















      I'm trying to get push notifications working in a Cordova app I'm working on. They work perfectly in the Android app and they work perfectly in the iOS app when it's in the foreground, but I don't receive any notifications when the app is in the background or terminated.



      I have the "Push Notifications" and "Background Modes - Remote notifications" capabilities enabled:



      xcode capabilities



      And I'm 100% sure the server has the device token (since push notifications are working in the foreground, and I can see it in the database).



      This is how I'm sending the push notification using the firebase-admin node module:



      await firebase.messaging().send(
      token: userDeviceToken,
      data: foo: 'bar',
      notification:
      title: 'This is a notification title',
      body: 'This is a notification body',
      ,
      );


      What am I missing?



      EDIT:



      If I launch the app or bring it to the foreground after it was supposed to receive a notification, it acts like it received an in-app notification. This happens even if I wait several minutes after the notification was sent before launching the app.







      ios node.js firebase push-notification firebase-cloud-messaging






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 22:45







      SimpleJ

















      asked Nov 15 '18 at 22:39









      SimpleJSimpleJ

      5,92042246




      5,92042246






















          2 Answers
          2






          active

          oldest

          votes


















          0














          You cannot receive remote notifications when the app is terminated. You may want to show a local notification telling the user that he cannot receive notifications anymore when the app is terminated.






          share|improve this answer























          • Do you have a link to the docs for this? I've added terminated PNs to iOS apps in the past. Is this a recent change? Wouldn't that break all sorts of apps that depend on receiving notifications when they're not running (like email or text messages)?

            – SimpleJ
            Nov 16 '18 at 16:55











          • You can receive remote notification when the app is in background but not when it is terminated. However, the system does not automatically launch your app if the user has force-quit it. developer.apple.com/documentation/uikit/uiapplicationdelegate/…

            – Victor Kwok
            Nov 17 '18 at 10:26












          • You might also want to set the priority as high as well. firebase.google.com/docs/cloud-messaging/admin/…

            – Victor Kwok
            Nov 17 '18 at 10:32


















          0














          Check the payload structure you received in the app while foreground. Normally it's different compared to Android. The iOS payload structure should be :




          "aps" :
          "alert" :
          "body" : "great match!",
          "title" : "Portugal vs. Denmark",
          ,
          "badge" : 1,
          ,
          "Custom_Data" : "Game level name"






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53328878%2fios-app-doesnt-receive-background-push-notifications-from-firebase%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You cannot receive remote notifications when the app is terminated. You may want to show a local notification telling the user that he cannot receive notifications anymore when the app is terminated.






            share|improve this answer























            • Do you have a link to the docs for this? I've added terminated PNs to iOS apps in the past. Is this a recent change? Wouldn't that break all sorts of apps that depend on receiving notifications when they're not running (like email or text messages)?

              – SimpleJ
              Nov 16 '18 at 16:55











            • You can receive remote notification when the app is in background but not when it is terminated. However, the system does not automatically launch your app if the user has force-quit it. developer.apple.com/documentation/uikit/uiapplicationdelegate/…

              – Victor Kwok
              Nov 17 '18 at 10:26












            • You might also want to set the priority as high as well. firebase.google.com/docs/cloud-messaging/admin/…

              – Victor Kwok
              Nov 17 '18 at 10:32















            0














            You cannot receive remote notifications when the app is terminated. You may want to show a local notification telling the user that he cannot receive notifications anymore when the app is terminated.






            share|improve this answer























            • Do you have a link to the docs for this? I've added terminated PNs to iOS apps in the past. Is this a recent change? Wouldn't that break all sorts of apps that depend on receiving notifications when they're not running (like email or text messages)?

              – SimpleJ
              Nov 16 '18 at 16:55











            • You can receive remote notification when the app is in background but not when it is terminated. However, the system does not automatically launch your app if the user has force-quit it. developer.apple.com/documentation/uikit/uiapplicationdelegate/…

              – Victor Kwok
              Nov 17 '18 at 10:26












            • You might also want to set the priority as high as well. firebase.google.com/docs/cloud-messaging/admin/…

              – Victor Kwok
              Nov 17 '18 at 10:32













            0












            0








            0







            You cannot receive remote notifications when the app is terminated. You may want to show a local notification telling the user that he cannot receive notifications anymore when the app is terminated.






            share|improve this answer













            You cannot receive remote notifications when the app is terminated. You may want to show a local notification telling the user that he cannot receive notifications anymore when the app is terminated.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 16 '18 at 4:24









            Victor KwokVictor Kwok

            906




            906












            • Do you have a link to the docs for this? I've added terminated PNs to iOS apps in the past. Is this a recent change? Wouldn't that break all sorts of apps that depend on receiving notifications when they're not running (like email or text messages)?

              – SimpleJ
              Nov 16 '18 at 16:55











            • You can receive remote notification when the app is in background but not when it is terminated. However, the system does not automatically launch your app if the user has force-quit it. developer.apple.com/documentation/uikit/uiapplicationdelegate/…

              – Victor Kwok
              Nov 17 '18 at 10:26












            • You might also want to set the priority as high as well. firebase.google.com/docs/cloud-messaging/admin/…

              – Victor Kwok
              Nov 17 '18 at 10:32

















            • Do you have a link to the docs for this? I've added terminated PNs to iOS apps in the past. Is this a recent change? Wouldn't that break all sorts of apps that depend on receiving notifications when they're not running (like email or text messages)?

              – SimpleJ
              Nov 16 '18 at 16:55











            • You can receive remote notification when the app is in background but not when it is terminated. However, the system does not automatically launch your app if the user has force-quit it. developer.apple.com/documentation/uikit/uiapplicationdelegate/…

              – Victor Kwok
              Nov 17 '18 at 10:26












            • You might also want to set the priority as high as well. firebase.google.com/docs/cloud-messaging/admin/…

              – Victor Kwok
              Nov 17 '18 at 10:32
















            Do you have a link to the docs for this? I've added terminated PNs to iOS apps in the past. Is this a recent change? Wouldn't that break all sorts of apps that depend on receiving notifications when they're not running (like email or text messages)?

            – SimpleJ
            Nov 16 '18 at 16:55





            Do you have a link to the docs for this? I've added terminated PNs to iOS apps in the past. Is this a recent change? Wouldn't that break all sorts of apps that depend on receiving notifications when they're not running (like email or text messages)?

            – SimpleJ
            Nov 16 '18 at 16:55













            You can receive remote notification when the app is in background but not when it is terminated. However, the system does not automatically launch your app if the user has force-quit it. developer.apple.com/documentation/uikit/uiapplicationdelegate/…

            – Victor Kwok
            Nov 17 '18 at 10:26






            You can receive remote notification when the app is in background but not when it is terminated. However, the system does not automatically launch your app if the user has force-quit it. developer.apple.com/documentation/uikit/uiapplicationdelegate/…

            – Victor Kwok
            Nov 17 '18 at 10:26














            You might also want to set the priority as high as well. firebase.google.com/docs/cloud-messaging/admin/…

            – Victor Kwok
            Nov 17 '18 at 10:32





            You might also want to set the priority as high as well. firebase.google.com/docs/cloud-messaging/admin/…

            – Victor Kwok
            Nov 17 '18 at 10:32













            0














            Check the payload structure you received in the app while foreground. Normally it's different compared to Android. The iOS payload structure should be :




            "aps" :
            "alert" :
            "body" : "great match!",
            "title" : "Portugal vs. Denmark",
            ,
            "badge" : 1,
            ,
            "Custom_Data" : "Game level name"






            share|improve this answer





























              0














              Check the payload structure you received in the app while foreground. Normally it's different compared to Android. The iOS payload structure should be :




              "aps" :
              "alert" :
              "body" : "great match!",
              "title" : "Portugal vs. Denmark",
              ,
              "badge" : 1,
              ,
              "Custom_Data" : "Game level name"






              share|improve this answer



























                0












                0








                0







                Check the payload structure you received in the app while foreground. Normally it's different compared to Android. The iOS payload structure should be :




                "aps" :
                "alert" :
                "body" : "great match!",
                "title" : "Portugal vs. Denmark",
                ,
                "badge" : 1,
                ,
                "Custom_Data" : "Game level name"






                share|improve this answer















                Check the payload structure you received in the app while foreground. Normally it's different compared to Android. The iOS payload structure should be :




                "aps" :
                "alert" :
                "body" : "great match!",
                "title" : "Portugal vs. Denmark",
                ,
                "badge" : 1,
                ,
                "Custom_Data" : "Game level name"







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 20 '18 at 11:07

























                answered Nov 20 '18 at 10:51









                Abhijith PurushothamanAbhijith Purushothaman

                612818




                612818



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53328878%2fios-app-doesnt-receive-background-push-notifications-from-firebase%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    ReactJS Fetched API data displays live - need Data displayed static

                    Evgeni Malkin