gpt4 book ai didi

push-notification - Firebase 静默 apns 通知

转载 作者:行者123 更新时间:2023-12-03 10:31:42 29 4
gpt4 key购买 nike

有没有办法使用谷歌的 firebase 发送一个无声的 APNS?
似乎如果应用程序在后台,它总是会向用户显示通知。

谢谢?

最佳答案

您可以使用 FCM 服务器 API 发送静默 APNS 消息
https://firebase.google.com/docs/cloud-messaging/http-server-ref

特别是你需要使用:

  • 数据字段:

  • This parameter specifies the custom key-value pairs of the message's payload.

    For example, with data:{"score":"3x1"}:

    On iOS, if the message is sent via APNS, it represents the custom data fields. If it is sent via FCM connection server, it would be represented as key value dictionary in AppDelegate application:didReceiveRemoteNotification:.

    The key should not be a reserved word ("from" or any word starting with "google" or "gcm"). Do not use any of the words defined in this table (such as collapse_key).

    Values in string types are recommended. You have to convert values in objects or other non-string data types (e.g., integers or booleans) to string


  • 内容可用字段:

  • On iOS, use this field to represent content-available in the APNS payload. When a notification or message is sent and this is set to true, an inactive client app is awoken. On Android, data messages wake the app by default. On Chrome, currently not supported.



    完整文档:
    https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream-http-messages-json

    关于push-notification - Firebase 静默 apns 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37570200/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com