Firebase Cloud Messaging click_action format is platform specific?

女生的网名这么多〃 提交于 2019-12-19 08:04:13

问题


I am using Firebase Cloud Messaging to send notifications to clients of my app. The clients can be any of the three supported platforms (ios, android, web).

I want the user to be able to click on the notification to launch the app.
For this i have to specify a click_action in the notification. For ios and android that seems to be a simple string. For web it would be an url.

How am i supposed to send a notification that works for a potentially mixed set of devices?

Do i have to separate the devices and send different messages to them?


回答1:


FCM works based on IDs generated by devices which are different depending on the device, platform, and curl session. So, they would be different for Android, iOS and Web. If you want to send to all platforms, you have to call the method three times (once for each platform) with a different payload or curl session for each. I'm sending to two platforms (iOS and Android) with two different function and calling them at the same time.




回答2:


Update: A recent feature was added for FCM that gives an option to provide specific params for specific platforms, called Platform Overrides.


Each platform may handle the same notification differently depending on your payload.

The click_action parameter is supported for all 3 platforms (Android, iOS, Web):

The action associated with a user click on the notification.

Each having different notes:

  • Android

    If specified, an activity with a matching intent filter is launched when a user clicks on the notification.

  • iOS

    Corresponds to category in the APNs payload.

  • Web

    For all URL values, secure HTTPS is required.

The note for Web doesn't say that you can only have URLs as it's value, just that IF it is a URL, it should have secure HTTPS (for security reasons).

It is okay to send a single notification for all platforms, so long as you are able to handle them accordingly and to you're liking. However, as also advised in the other answer, it is better for you to send different payloads depending on the platform.



来源:https://stackoverflow.com/questions/42297505/firebase-cloud-messaging-click-action-format-is-platform-specific

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!