FCM Firebase push notification Android/iOS










2














I'm using FCM to send notifications for a project in booth plattforms, iOS and Android. Following are the payloads I'm sending:



 
"to":"user_key",
"priority":"high",
"content_available":true,
"mutable_content":true,
"data":
"body":"test"




After reading the Firebase documentation, the behaviour when sending notification and data payload through FCM is:



iOS



  • You won't see banner if notification -> body is not defined.

Android



  • If you pass data payload only, it will receive data when is in background.

  • If you pass notification_payload, system tray will handle it.

The thing is:



For Android I want to avoid to pass notification_payload in order to receive data when app is in background (in this way onMessageReceived() will be called). But then, I won´t receive notifications in iOS.



Help/Suggestions appreciated.










share|improve this question




























    2














    I'm using FCM to send notifications for a project in booth plattforms, iOS and Android. Following are the payloads I'm sending:



     
    "to":"user_key",
    "priority":"high",
    "content_available":true,
    "mutable_content":true,
    "data":
    "body":"test"




    After reading the Firebase documentation, the behaviour when sending notification and data payload through FCM is:



    iOS



    • You won't see banner if notification -> body is not defined.

    Android



    • If you pass data payload only, it will receive data when is in background.

    • If you pass notification_payload, system tray will handle it.

    The thing is:



    For Android I want to avoid to pass notification_payload in order to receive data when app is in background (in this way onMessageReceived() will be called). But then, I won´t receive notifications in iOS.



    Help/Suggestions appreciated.










    share|improve this question


























      2












      2








      2


      0





      I'm using FCM to send notifications for a project in booth plattforms, iOS and Android. Following are the payloads I'm sending:



       
      "to":"user_key",
      "priority":"high",
      "content_available":true,
      "mutable_content":true,
      "data":
      "body":"test"




      After reading the Firebase documentation, the behaviour when sending notification and data payload through FCM is:



      iOS



      • You won't see banner if notification -> body is not defined.

      Android



      • If you pass data payload only, it will receive data when is in background.

      • If you pass notification_payload, system tray will handle it.

      The thing is:



      For Android I want to avoid to pass notification_payload in order to receive data when app is in background (in this way onMessageReceived() will be called). But then, I won´t receive notifications in iOS.



      Help/Suggestions appreciated.










      share|improve this question















      I'm using FCM to send notifications for a project in booth plattforms, iOS and Android. Following are the payloads I'm sending:



       
      "to":"user_key",
      "priority":"high",
      "content_available":true,
      "mutable_content":true,
      "data":
      "body":"test"




      After reading the Firebase documentation, the behaviour when sending notification and data payload through FCM is:



      iOS



      • You won't see banner if notification -> body is not defined.

      Android



      • If you pass data payload only, it will receive data when is in background.

      • If you pass notification_payload, system tray will handle it.

      The thing is:



      For Android I want to avoid to pass notification_payload in order to receive data when app is in background (in this way onMessageReceived() will be called). But then, I won´t receive notifications in iOS.



      Help/Suggestions appreciated.







      android ios firebase push-notification firebase-cloud-messaging






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 11:58

























      asked Nov 12 at 9:48









      IrApp

      6311030




      6311030






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Server should use different json structures for IOS and Android push request. For example:



          Android:



          [data] => Array
          (
          [title] => Test
          [message] => Message
          )


          IOS:



          [notification] => Array
          (
          [title] => Title
          [body] => Body
          [sound] => 1
          [vibrate] => 1
          )

          [data] => Array
          (
          [custom_key] => custom_value
          )


          You can edit it according to your task.






          share|improve this answer




















          • I'm using Firebase Cloud Messaging, can't handle that.
            – IrApp
            Nov 12 at 11:51










          • Sorry, could you clarify. Are you just testing in the firebase console for sending notifications?
            – Onix
            Nov 12 at 11:52










          • I have a project in both platforms, Android and iOS. I'm implementing Firebase push notifications for booth projects. Question edited.
            – IrApp
            Nov 12 at 11:57











          • Understood, but someone should execute the sending of push notification into mobile platforms. For example, API? Where does the sending process begin?
            – Onix
            Nov 12 at 12:00










          • DOCU: firebase.google.com/docs/cloud-messaging/… , API: fcm.googleapis.com/fcm/send
            – IrApp
            Nov 12 at 12:02











          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%2f53259518%2ffcm-firebase-push-notification-android-ios%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Server should use different json structures for IOS and Android push request. For example:



          Android:



          [data] => Array
          (
          [title] => Test
          [message] => Message
          )


          IOS:



          [notification] => Array
          (
          [title] => Title
          [body] => Body
          [sound] => 1
          [vibrate] => 1
          )

          [data] => Array
          (
          [custom_key] => custom_value
          )


          You can edit it according to your task.






          share|improve this answer




















          • I'm using Firebase Cloud Messaging, can't handle that.
            – IrApp
            Nov 12 at 11:51










          • Sorry, could you clarify. Are you just testing in the firebase console for sending notifications?
            – Onix
            Nov 12 at 11:52










          • I have a project in both platforms, Android and iOS. I'm implementing Firebase push notifications for booth projects. Question edited.
            – IrApp
            Nov 12 at 11:57











          • Understood, but someone should execute the sending of push notification into mobile platforms. For example, API? Where does the sending process begin?
            – Onix
            Nov 12 at 12:00










          • DOCU: firebase.google.com/docs/cloud-messaging/… , API: fcm.googleapis.com/fcm/send
            – IrApp
            Nov 12 at 12:02
















          0














          Server should use different json structures for IOS and Android push request. For example:



          Android:



          [data] => Array
          (
          [title] => Test
          [message] => Message
          )


          IOS:



          [notification] => Array
          (
          [title] => Title
          [body] => Body
          [sound] => 1
          [vibrate] => 1
          )

          [data] => Array
          (
          [custom_key] => custom_value
          )


          You can edit it according to your task.






          share|improve this answer




















          • I'm using Firebase Cloud Messaging, can't handle that.
            – IrApp
            Nov 12 at 11:51










          • Sorry, could you clarify. Are you just testing in the firebase console for sending notifications?
            – Onix
            Nov 12 at 11:52










          • I have a project in both platforms, Android and iOS. I'm implementing Firebase push notifications for booth projects. Question edited.
            – IrApp
            Nov 12 at 11:57











          • Understood, but someone should execute the sending of push notification into mobile platforms. For example, API? Where does the sending process begin?
            – Onix
            Nov 12 at 12:00










          • DOCU: firebase.google.com/docs/cloud-messaging/… , API: fcm.googleapis.com/fcm/send
            – IrApp
            Nov 12 at 12:02














          0












          0








          0






          Server should use different json structures for IOS and Android push request. For example:



          Android:



          [data] => Array
          (
          [title] => Test
          [message] => Message
          )


          IOS:



          [notification] => Array
          (
          [title] => Title
          [body] => Body
          [sound] => 1
          [vibrate] => 1
          )

          [data] => Array
          (
          [custom_key] => custom_value
          )


          You can edit it according to your task.






          share|improve this answer












          Server should use different json structures for IOS and Android push request. For example:



          Android:



          [data] => Array
          (
          [title] => Test
          [message] => Message
          )


          IOS:



          [notification] => Array
          (
          [title] => Title
          [body] => Body
          [sound] => 1
          [vibrate] => 1
          )

          [data] => Array
          (
          [custom_key] => custom_value
          )


          You can edit it according to your task.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 at 11:44









          Onix

          4128




          4128











          • I'm using Firebase Cloud Messaging, can't handle that.
            – IrApp
            Nov 12 at 11:51










          • Sorry, could you clarify. Are you just testing in the firebase console for sending notifications?
            – Onix
            Nov 12 at 11:52










          • I have a project in both platforms, Android and iOS. I'm implementing Firebase push notifications for booth projects. Question edited.
            – IrApp
            Nov 12 at 11:57











          • Understood, but someone should execute the sending of push notification into mobile platforms. For example, API? Where does the sending process begin?
            – Onix
            Nov 12 at 12:00










          • DOCU: firebase.google.com/docs/cloud-messaging/… , API: fcm.googleapis.com/fcm/send
            – IrApp
            Nov 12 at 12:02

















          • I'm using Firebase Cloud Messaging, can't handle that.
            – IrApp
            Nov 12 at 11:51










          • Sorry, could you clarify. Are you just testing in the firebase console for sending notifications?
            – Onix
            Nov 12 at 11:52










          • I have a project in both platforms, Android and iOS. I'm implementing Firebase push notifications for booth projects. Question edited.
            – IrApp
            Nov 12 at 11:57











          • Understood, but someone should execute the sending of push notification into mobile platforms. For example, API? Where does the sending process begin?
            – Onix
            Nov 12 at 12:00










          • DOCU: firebase.google.com/docs/cloud-messaging/… , API: fcm.googleapis.com/fcm/send
            – IrApp
            Nov 12 at 12:02
















          I'm using Firebase Cloud Messaging, can't handle that.
          – IrApp
          Nov 12 at 11:51




          I'm using Firebase Cloud Messaging, can't handle that.
          – IrApp
          Nov 12 at 11:51












          Sorry, could you clarify. Are you just testing in the firebase console for sending notifications?
          – Onix
          Nov 12 at 11:52




          Sorry, could you clarify. Are you just testing in the firebase console for sending notifications?
          – Onix
          Nov 12 at 11:52












          I have a project in both platforms, Android and iOS. I'm implementing Firebase push notifications for booth projects. Question edited.
          – IrApp
          Nov 12 at 11:57





          I have a project in both platforms, Android and iOS. I'm implementing Firebase push notifications for booth projects. Question edited.
          – IrApp
          Nov 12 at 11:57













          Understood, but someone should execute the sending of push notification into mobile platforms. For example, API? Where does the sending process begin?
          – Onix
          Nov 12 at 12:00




          Understood, but someone should execute the sending of push notification into mobile platforms. For example, API? Where does the sending process begin?
          – Onix
          Nov 12 at 12:00












          DOCU: firebase.google.com/docs/cloud-messaging/… , API: fcm.googleapis.com/fcm/send
          – IrApp
          Nov 12 at 12:02





          DOCU: firebase.google.com/docs/cloud-messaging/… , API: fcm.googleapis.com/fcm/send
          – IrApp
          Nov 12 at 12:02


















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f53259518%2ffcm-firebase-push-notification-android-ios%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







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3