从iOS 13和watchOS 6开始,苹果需要有标题apns-push-type (这个标题的值可以是alert或background)来进行推送通知。
根据苹果公司的文件:
此标头的值必须准确地反映通知的有效负载的内容。如果存在不匹配,或者所需系统上缺少标头,则APN可能会延迟通知的传递或完全删除通知。
HEADERS
- END_STREAM
+ END_HEADERS
:method = POST
:scheme = https
:path = /3/device/xxxxxx
host = api.sandbox.push.apple.com
authorization = bearer xxx
apns-id = xxx-xxx-xxx
apns-push-type = alert
apns-expiration = 0
apns-priority = 10
apns-topic = com.example.MyApp
DATA
+ END_STREAM
{ "aps" : { "alert" : "Hello" } }不幸的是,使用蔚蓝通知中心,我只能定义aps内容,而不能定义标头。
{ "aps": { "alert":"Alert message!", "content-available": 1 }, "CustomData": "$(CustomData)" }它是如何处理的天青通知枢纽?如何指定通知的类型?
发布于 2019-09-26 15:20:25
经过一些实验和一些调查,这是目前的Azure服务器行为.
服务器检查通知的内容,以推断正确的值。
如果“content”:1存在并且缺少“警告”,那么"apns-push-type" = "background"将被添加到标头中。
如果存在有效的“警报”,则将"apns-push-type" = "alert"添加到标头中。
因此,请注意拥有一个有效的APNS主体,并具有正确填充的内容可用/警报属性。
有关更多信息,请参见此讨论线
更新2019-10-15:当前背景无声通知存在一些问题,请参见以下讨论:https://github.com/Azure/azure-notificationhubs-dotnet/issues/96
更新2019-11-25:服务器拒绝针对包含报头的APNS安装。现在,这个问题已经解决了,静默通知应该像预期的那样工作。
发布于 2019-10-03 21:35:32
这个答案是不准确的,背景推送现在并不适用于天蓝色。在发送推送时,需要包括标题,如下所示,集线器还需要配置密钥,而不是证书:
var backgroundHeaders = new Dictionary<string, string> { { "apns-push-type", "background" }, { "apns-priority", "5" } };
Dictionary<string, string> templateParams = new Dictionary<string, string>();
// populated templateParams
var notification = new TemplateNotification(templateParams);
notification.Headers = backgroundHeaders;
// the second parameter is the tag name and the template name as we have it registered from the device.
var resBack = await hubClient.SendNotificationAsync(notification, tags);https://stackoverflow.com/questions/58119594
复制相似问题