FCM from multiple senders but within the same app










0















How can i send multiple notifications using FCM but within the same server side, and be able to distinguish between notification x and y on the client side and send them to different Notification Channel?



maybe with




RemoteMessage.getFrom?




EDIT
I tried setting notification_id and it does not work.



EDIT:
I can add a Data payload and restrict the notification in one of my classes and add a switch statement which will divide according to my Notification but i need to handle the data in the background and not foreground.










share|improve this question
























  • Do you want N senders to 1 device?

    – Gonzalo
    Nov 13 '18 at 11:45











  • within the same app, yes. so if (x happens) send notification x else if(y happens) send notification y and client app can receive x and y how can i distinguish between x and y?

    – KARAM JABER
    Nov 13 '18 at 11:54











  • I did something similar but in the other direction, 1 sender for N devices. What I did was to create a firebase function that reads from a collection, insert in that collection different messages. The function would read the message data, like sender, receiver, event, message, everything you want. In my case it reads message from 1 sender and fire FCM for all the devices subscribed to him, some code: github.com/Fic-Spinoff/family-care-firebase

    – Gonzalo
    Nov 13 '18 at 12:00















0















How can i send multiple notifications using FCM but within the same server side, and be able to distinguish between notification x and y on the client side and send them to different Notification Channel?



maybe with




RemoteMessage.getFrom?




EDIT
I tried setting notification_id and it does not work.



EDIT:
I can add a Data payload and restrict the notification in one of my classes and add a switch statement which will divide according to my Notification but i need to handle the data in the background and not foreground.










share|improve this question
























  • Do you want N senders to 1 device?

    – Gonzalo
    Nov 13 '18 at 11:45











  • within the same app, yes. so if (x happens) send notification x else if(y happens) send notification y and client app can receive x and y how can i distinguish between x and y?

    – KARAM JABER
    Nov 13 '18 at 11:54











  • I did something similar but in the other direction, 1 sender for N devices. What I did was to create a firebase function that reads from a collection, insert in that collection different messages. The function would read the message data, like sender, receiver, event, message, everything you want. In my case it reads message from 1 sender and fire FCM for all the devices subscribed to him, some code: github.com/Fic-Spinoff/family-care-firebase

    – Gonzalo
    Nov 13 '18 at 12:00













0












0








0








How can i send multiple notifications using FCM but within the same server side, and be able to distinguish between notification x and y on the client side and send them to different Notification Channel?



maybe with




RemoteMessage.getFrom?




EDIT
I tried setting notification_id and it does not work.



EDIT:
I can add a Data payload and restrict the notification in one of my classes and add a switch statement which will divide according to my Notification but i need to handle the data in the background and not foreground.










share|improve this question
















How can i send multiple notifications using FCM but within the same server side, and be able to distinguish between notification x and y on the client side and send them to different Notification Channel?



maybe with




RemoteMessage.getFrom?




EDIT
I tried setting notification_id and it does not work.



EDIT:
I can add a Data payload and restrict the notification in one of my classes and add a switch statement which will divide according to my Notification but i need to handle the data in the background and not foreground.







android firebase firebase-cloud-messaging






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 13:14







KARAM JABER

















asked Nov 13 '18 at 11:18









KARAM JABERKARAM JABER

528




528












  • Do you want N senders to 1 device?

    – Gonzalo
    Nov 13 '18 at 11:45











  • within the same app, yes. so if (x happens) send notification x else if(y happens) send notification y and client app can receive x and y how can i distinguish between x and y?

    – KARAM JABER
    Nov 13 '18 at 11:54











  • I did something similar but in the other direction, 1 sender for N devices. What I did was to create a firebase function that reads from a collection, insert in that collection different messages. The function would read the message data, like sender, receiver, event, message, everything you want. In my case it reads message from 1 sender and fire FCM for all the devices subscribed to him, some code: github.com/Fic-Spinoff/family-care-firebase

    – Gonzalo
    Nov 13 '18 at 12:00

















  • Do you want N senders to 1 device?

    – Gonzalo
    Nov 13 '18 at 11:45











  • within the same app, yes. so if (x happens) send notification x else if(y happens) send notification y and client app can receive x and y how can i distinguish between x and y?

    – KARAM JABER
    Nov 13 '18 at 11:54











  • I did something similar but in the other direction, 1 sender for N devices. What I did was to create a firebase function that reads from a collection, insert in that collection different messages. The function would read the message data, like sender, receiver, event, message, everything you want. In my case it reads message from 1 sender and fire FCM for all the devices subscribed to him, some code: github.com/Fic-Spinoff/family-care-firebase

    – Gonzalo
    Nov 13 '18 at 12:00
















Do you want N senders to 1 device?

– Gonzalo
Nov 13 '18 at 11:45





Do you want N senders to 1 device?

– Gonzalo
Nov 13 '18 at 11:45













within the same app, yes. so if (x happens) send notification x else if(y happens) send notification y and client app can receive x and y how can i distinguish between x and y?

– KARAM JABER
Nov 13 '18 at 11:54





within the same app, yes. so if (x happens) send notification x else if(y happens) send notification y and client app can receive x and y how can i distinguish between x and y?

– KARAM JABER
Nov 13 '18 at 11:54













I did something similar but in the other direction, 1 sender for N devices. What I did was to create a firebase function that reads from a collection, insert in that collection different messages. The function would read the message data, like sender, receiver, event, message, everything you want. In my case it reads message from 1 sender and fire FCM for all the devices subscribed to him, some code: github.com/Fic-Spinoff/family-care-firebase

– Gonzalo
Nov 13 '18 at 12:00





I did something similar but in the other direction, 1 sender for N devices. What I did was to create a firebase function that reads from a collection, insert in that collection different messages. The function would read the message data, like sender, receiver, event, message, everything you want. In my case it reads message from 1 sender and fire FCM for all the devices subscribed to him, some code: github.com/Fic-Spinoff/family-care-firebase

– Gonzalo
Nov 13 '18 at 12:00












2 Answers
2






active

oldest

votes


















1














Create the notification_key, which identifies the device group by mapping a particular group (typically a user) to all of the group's associated registration tokens. You can create notification keys on the app server or on Android client apps.



please check this link
https://firebase.google.com/docs/cloud-messaging/android/device-group






share|improve this answer























  • I dont want to send a single notification to multiple devices... i want to send multiple notification from different senders within the same app to a single device.... thanks for trying though.

    – KARAM JABER
    Nov 13 '18 at 11:41












  • when you defining notification_key, you can assign that key for single device and send multiple notification just to that single device which has that key

    – Amir
    Nov 13 '18 at 11:49












  • yes but you are still restricting to one app, i want to define multiple senders to same app if i assign a notification key only the notifications with key will be called from the same app...

    – KARAM JABER
    Nov 13 '18 at 11:56


















0














Answering the question in the title: FCM from multiple senders but within the same app



If sender == Firebase Project then I don't think it is possible.



If sender == a client inside the same Firebase Project (like an iOS app, multiple servers, another Android app), then you need to create those apps inside your Firebase Project (for iOS and Android apps) and use the server key (for the servers)



If sender == function (like "Update Entity A", "show notification for promotion", etc), then you can use the data field inside the notification. We usually add an action field inside the data field. Both the receiver (iOS or Android app) and the sender (usually a server, but can also be a mobile app) know the list of possible actions. Receivers know what to do when they receive them (if app receives "Update Entity A", then it starts the EntityAUpdateService).






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%2f53279860%2ffcm-from-multiple-senders-but-within-the-same-app%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









    1














    Create the notification_key, which identifies the device group by mapping a particular group (typically a user) to all of the group's associated registration tokens. You can create notification keys on the app server or on Android client apps.



    please check this link
    https://firebase.google.com/docs/cloud-messaging/android/device-group






    share|improve this answer























    • I dont want to send a single notification to multiple devices... i want to send multiple notification from different senders within the same app to a single device.... thanks for trying though.

      – KARAM JABER
      Nov 13 '18 at 11:41












    • when you defining notification_key, you can assign that key for single device and send multiple notification just to that single device which has that key

      – Amir
      Nov 13 '18 at 11:49












    • yes but you are still restricting to one app, i want to define multiple senders to same app if i assign a notification key only the notifications with key will be called from the same app...

      – KARAM JABER
      Nov 13 '18 at 11:56















    1














    Create the notification_key, which identifies the device group by mapping a particular group (typically a user) to all of the group's associated registration tokens. You can create notification keys on the app server or on Android client apps.



    please check this link
    https://firebase.google.com/docs/cloud-messaging/android/device-group






    share|improve this answer























    • I dont want to send a single notification to multiple devices... i want to send multiple notification from different senders within the same app to a single device.... thanks for trying though.

      – KARAM JABER
      Nov 13 '18 at 11:41












    • when you defining notification_key, you can assign that key for single device and send multiple notification just to that single device which has that key

      – Amir
      Nov 13 '18 at 11:49












    • yes but you are still restricting to one app, i want to define multiple senders to same app if i assign a notification key only the notifications with key will be called from the same app...

      – KARAM JABER
      Nov 13 '18 at 11:56













    1












    1








    1







    Create the notification_key, which identifies the device group by mapping a particular group (typically a user) to all of the group's associated registration tokens. You can create notification keys on the app server or on Android client apps.



    please check this link
    https://firebase.google.com/docs/cloud-messaging/android/device-group






    share|improve this answer













    Create the notification_key, which identifies the device group by mapping a particular group (typically a user) to all of the group's associated registration tokens. You can create notification keys on the app server or on Android client apps.



    please check this link
    https://firebase.google.com/docs/cloud-messaging/android/device-group







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 13 '18 at 11:37









    AmirAmir

    159214




    159214












    • I dont want to send a single notification to multiple devices... i want to send multiple notification from different senders within the same app to a single device.... thanks for trying though.

      – KARAM JABER
      Nov 13 '18 at 11:41












    • when you defining notification_key, you can assign that key for single device and send multiple notification just to that single device which has that key

      – Amir
      Nov 13 '18 at 11:49












    • yes but you are still restricting to one app, i want to define multiple senders to same app if i assign a notification key only the notifications with key will be called from the same app...

      – KARAM JABER
      Nov 13 '18 at 11:56

















    • I dont want to send a single notification to multiple devices... i want to send multiple notification from different senders within the same app to a single device.... thanks for trying though.

      – KARAM JABER
      Nov 13 '18 at 11:41












    • when you defining notification_key, you can assign that key for single device and send multiple notification just to that single device which has that key

      – Amir
      Nov 13 '18 at 11:49












    • yes but you are still restricting to one app, i want to define multiple senders to same app if i assign a notification key only the notifications with key will be called from the same app...

      – KARAM JABER
      Nov 13 '18 at 11:56
















    I dont want to send a single notification to multiple devices... i want to send multiple notification from different senders within the same app to a single device.... thanks for trying though.

    – KARAM JABER
    Nov 13 '18 at 11:41






    I dont want to send a single notification to multiple devices... i want to send multiple notification from different senders within the same app to a single device.... thanks for trying though.

    – KARAM JABER
    Nov 13 '18 at 11:41














    when you defining notification_key, you can assign that key for single device and send multiple notification just to that single device which has that key

    – Amir
    Nov 13 '18 at 11:49






    when you defining notification_key, you can assign that key for single device and send multiple notification just to that single device which has that key

    – Amir
    Nov 13 '18 at 11:49














    yes but you are still restricting to one app, i want to define multiple senders to same app if i assign a notification key only the notifications with key will be called from the same app...

    – KARAM JABER
    Nov 13 '18 at 11:56





    yes but you are still restricting to one app, i want to define multiple senders to same app if i assign a notification key only the notifications with key will be called from the same app...

    – KARAM JABER
    Nov 13 '18 at 11:56













    0














    Answering the question in the title: FCM from multiple senders but within the same app



    If sender == Firebase Project then I don't think it is possible.



    If sender == a client inside the same Firebase Project (like an iOS app, multiple servers, another Android app), then you need to create those apps inside your Firebase Project (for iOS and Android apps) and use the server key (for the servers)



    If sender == function (like "Update Entity A", "show notification for promotion", etc), then you can use the data field inside the notification. We usually add an action field inside the data field. Both the receiver (iOS or Android app) and the sender (usually a server, but can also be a mobile app) know the list of possible actions. Receivers know what to do when they receive them (if app receives "Update Entity A", then it starts the EntityAUpdateService).






    share|improve this answer



























      0














      Answering the question in the title: FCM from multiple senders but within the same app



      If sender == Firebase Project then I don't think it is possible.



      If sender == a client inside the same Firebase Project (like an iOS app, multiple servers, another Android app), then you need to create those apps inside your Firebase Project (for iOS and Android apps) and use the server key (for the servers)



      If sender == function (like "Update Entity A", "show notification for promotion", etc), then you can use the data field inside the notification. We usually add an action field inside the data field. Both the receiver (iOS or Android app) and the sender (usually a server, but can also be a mobile app) know the list of possible actions. Receivers know what to do when they receive them (if app receives "Update Entity A", then it starts the EntityAUpdateService).






      share|improve this answer

























        0












        0








        0







        Answering the question in the title: FCM from multiple senders but within the same app



        If sender == Firebase Project then I don't think it is possible.



        If sender == a client inside the same Firebase Project (like an iOS app, multiple servers, another Android app), then you need to create those apps inside your Firebase Project (for iOS and Android apps) and use the server key (for the servers)



        If sender == function (like "Update Entity A", "show notification for promotion", etc), then you can use the data field inside the notification. We usually add an action field inside the data field. Both the receiver (iOS or Android app) and the sender (usually a server, but can also be a mobile app) know the list of possible actions. Receivers know what to do when they receive them (if app receives "Update Entity A", then it starts the EntityAUpdateService).






        share|improve this answer













        Answering the question in the title: FCM from multiple senders but within the same app



        If sender == Firebase Project then I don't think it is possible.



        If sender == a client inside the same Firebase Project (like an iOS app, multiple servers, another Android app), then you need to create those apps inside your Firebase Project (for iOS and Android apps) and use the server key (for the servers)



        If sender == function (like "Update Entity A", "show notification for promotion", etc), then you can use the data field inside the notification. We usually add an action field inside the data field. Both the receiver (iOS or Android app) and the sender (usually a server, but can also be a mobile app) know the list of possible actions. Receivers know what to do when they receive them (if app receives "Update Entity A", then it starts the EntityAUpdateService).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 '18 at 13:26









        David CorsaliniDavid Corsalini

        4,04133151




        4,04133151



























            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%2f53279860%2ffcm-from-multiple-senders-but-within-the-same-app%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







            這個網誌中的熱門文章

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

            In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

            Museum of Modern and Contemporary Art of Trento and Rovereto