Firebase 拉取通知
Firebase Pull notification
我正在使用 Firebase 云消息传递。我有几个问题无法从文档中理解:
- Android:假设应用程序已关闭(非后台:已关闭)。如果我发送的通知也包含数据负载,则此数据负载会通过 Intent Extra
传递给 activity
Messages with both notification and data payload, both background and
foreground. In this case, the notification is delivered to the
device’s system tray, and the data payload is delivered in the extras
of the intent of your launcher Activity.
如果用户没有点击通知怎么办?数据负载是否丢失?有办法找回吗?
- iOS/Android。假设用户禁用了通知并且我向客户端发送了通知:有没有办法在应用程序启动时检索(拉取)通知?
非常感谢
如果您的应用程序在后台运行,Firebase 将不会触发 onMessageReceived()。为什么.....?我不知道。在这种情况下,我认为实施 FirebaseMessagingService 没有任何意义。
根据文档,如果你想处理后台消息到达,你必须发送 'click_action' 和你的消息。但是如果你从 Firebase 控制台发送消息,那是不可能的,只能通过 Firebase API。这意味着您必须构建自己的 "console" 才能让营销人员使用它。所以,这使得 Firebase 控制台也变得毫无用处!
这个新工具背后的想法非常好,很有前途,但执行得很糟糕。
我想我们将不得不等待新版本 improvements/fixes
如果应用程序关闭(不在后台),则会在收到通知时调用 onMessageReceived 方法,您可以在此处使用 remoteMessage.getData().get("key_for_parameter");
检索数据负载,其中 key_for_parameter 是您在通知中发送的参数。即使应用程序关闭,也会调用此方法。但是,请注意,仅当您在通知中省略 "notification" 参数时才会调用 "onMessageReceived"(查看 )
因此,一旦您在 onMessageReceived 中有了参数,您就可以寻找一种策略在您的应用程序中使用它们,例如存储在数据库中,如果用户不单击通知,您也不会丢失数据。
我正在使用 Firebase 云消息传递。我有几个问题无法从文档中理解:
- Android:假设应用程序已关闭(非后台:已关闭)。如果我发送的通知也包含数据负载,则此数据负载会通过 Intent Extra 传递给 activity
Messages with both notification and data payload, both background and foreground. In this case, the notification is delivered to the device’s system tray, and the data payload is delivered in the extras of the intent of your launcher Activity.
如果用户没有点击通知怎么办?数据负载是否丢失?有办法找回吗?
- iOS/Android。假设用户禁用了通知并且我向客户端发送了通知:有没有办法在应用程序启动时检索(拉取)通知?
非常感谢
如果您的应用程序在后台运行,Firebase 将不会触发 onMessageReceived()。为什么.....?我不知道。在这种情况下,我认为实施 FirebaseMessagingService 没有任何意义。
根据文档,如果你想处理后台消息到达,你必须发送 'click_action' 和你的消息。但是如果你从 Firebase 控制台发送消息,那是不可能的,只能通过 Firebase API。这意味着您必须构建自己的 "console" 才能让营销人员使用它。所以,这使得 Firebase 控制台也变得毫无用处!
这个新工具背后的想法非常好,很有前途,但执行得很糟糕。
我想我们将不得不等待新版本 improvements/fixes
如果应用程序关闭(不在后台),则会在收到通知时调用 onMessageReceived 方法,您可以在此处使用 remoteMessage.getData().get("key_for_parameter");
检索数据负载,其中 key_for_parameter 是您在通知中发送的参数。即使应用程序关闭,也会调用此方法。但是,请注意,仅当您在通知中省略 "notification" 参数时才会调用 "onMessageReceived"(查看
因此,一旦您在 onMessageReceived 中有了参数,您就可以寻找一种策略在您的应用程序中使用它们,例如存储在数据库中,如果用户不单击通知,您也不会丢失数据。