Firebase无声APS通知 [英] Firebase silent apns notification

本文介绍了Firebase无声APS通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用谷歌的firebase发送沉默的APNS?
似乎如果应用程序在后台,它会一直显示通知给用户。

谢谢?


<您可以使用FCM服务器API发送无提示APNS消息
解决方案

messaging / http-server-ref> https://firebase.google.com/docs/cloud-messaging/http-server-ref



在特别是您需要使用:


  • 数据字段:




此参数指定消息
有效负载的自定义键值对。



<例如,用数据:{score:3x1}:

在iOS上,如果消息是通过APNS发送的,则代表自定义数据
字段。如果它是通过FCM连接服务器发送的,那么在AppDelegate
application:didReceiveRemoteNotification:

中键值应该是
。不是一个保留字(from或者任何以
开始的词,用google或gcm)。不要使用这个
表中定义的任何单词(如collapse_key)。

建议使用字符串类型的值。您必须将
对象或其他非字符串数据类型(例如整数或布尔值)中的值转换为
字符串




  • content-available 字段:



    在iOS上,使用此字段来表示APNS
    有效内容中的可用内容。当发送通知或消息并将其设置为
    true时,会激活非活动客户端应用程序。在Android上,数据消息默认唤醒
    应用程序。在Chrome上,目前不支持。


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


    Is there a way to send a silent APNS using google's firebase? It seems that if the app is in the background it will always show a notification to the user.

    Thanks?

    解决方案

    You can send silent APNS messages using the FCM server API https://firebase.google.com/docs/cloud-messaging/http-server-ref

    In particular you need to use:

    • The data field:

    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

    • The content-available field:

    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.

    Full documentation: https://firebase.google.com/docs/cloud-messaging/http-server-ref#downstream-http-messages-json

    这篇关于Firebase无声APS通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆