如何从 iOS 上的 Firebase 通知中知道 "topic" 名称

How to know "topic" name from Firebase notification on iOS

我正在尝试在我的 iOS 应用程序中使用 Firebase。我成功地集成了它并从所有 3 个目标(用户段、主题和单个设备)接收了通知。 我的问题是如何知道从哪个主题收到了特定通知?

我正在关注这个 documentation and this github page

编辑:

我正在 iOS11.2 (XCode9.2) 上进行测试,我的回复 (userInfo) 是:

{
    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;
}

我收到 gcm.message_id 但它看起来像 "gcm.message_id" = "0:1512894251264950%38894e8e38894e8e"; 如何将其映射到我的主题名称?

谢谢。

我从 Firebase 支持团队得到了答案。

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.

看起来这在 Android 上有效,但在 iOS 上它今天不受支持(2017 年 12 月)