How to know "topic" name from Firebase notification on iOS
Asked Answered
B

1

6

I'm trying to use Firebase in my iOS application. I successfully integrated it and receiving notifications from all 3 Targets (user segment, topic and single device). My question is how to know a particular notification is received from which topic?

I'm following this documentation and this github page

EDIT:

I'm testing on iOS11.2 (XCode9.2) & my response (userInfo) is:

{
    aps =     {
        alert = test;
        sound = default;
    };
    "gcm.message_id" = "0:1513282329413512%38894e8e28894e8e";
    "gcm.n.e" = 1;
    "gcm.notification.sound2" = default;
    "google.c.a.c_id" = 1542306492273623048;
    "google.c.a.c_l" = test;
    "google.c.a.e" = 1;
    "google.c.a.ts" = 1513182256;
    "google.c.a.udt" = 0;
}

I'm getting gcm.message_id but it looks like "gcm.message_id" = "0:1512894251264950%38894e8e38894e8e"; How to map this to my topic name?

Thanks.

Beitch answered 10/12, 2017 at 8:42 Comment(4)
the user subscribes to the topic, when you send a notification using that topic then it means that the person who subscribed to that topic has recieved itDome
Yes. For e.g: I've subscribed to 10 topics. How to know out of those 10 topics, I received notification for which one?Beitch
how are u sending the notification from console?Dome
By selecting a topic. I'm receiving that notification also, just can't check the topic name in AppDelegate.Beitch
B
4

I got the answer from Firebase support team.

It doesn't seem like there's a way to get this info as per documentation. One workaround I can think of is if you would pass the topic name in your data payload, you can then manually handle it from your code and map it to your message_id.

So looks like this works on Android but on iOS it's not supported today (Dec 2017)

Beitch answered 14/12, 2017 at 7:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.