【问题标题】:iOS13 apns-push-type header on azure notification hub天蓝色通知中心上的 iOS13 apns-push-type 标头
【发布时间】:2019-09-26 14:58:23
【问题描述】:

从 iOS 13 和 watchOS 6 开始,Apple 要求存在标头 apns-push-type(此标头的值可以是 alertbackground)用于推送通知。

根据 Apple 文档:

此标头的值必须准确反映通知负载的内容。如果不匹配,或者所需系统上缺少标头,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" } }

see Apple doc

不幸的是,使用 azure 通知中心我只能定义 apscontent 而不能定义标题。

{ "aps": { "alert":"Alert message!", "content-available": 1 }, "CustomData": "$(CustomData)" }

Azure 通知中心如何处理它? 如何指定通知的类型?

【问题讨论】:

    标签: azure push-notification ios13 azure-notificationhub


    【解决方案1】:

    经过一些实验和一点点调查,这是当前 Azure 服务器行为...

    服务器检查通知的内容以推断正确的值。

    如果存在 "content-available": 1 并且缺少 "alert",则将 "apns-push-type" = "background" 添加到标题中。

    如果存在有效的“警报”,则将 "apns-push-type" = "alert" 添加到标题中。

    因此,请注意拥有一个有效的 APNS JSON 正文,以及正确填充的内容可用/警报属性。

    查看discussion thread了解更多信息

    2019 年 10 月 15 日更新: 目前后台静默通知存在一些问题 请参阅以下讨论: https://github.com/Azure/azure-notificationhubs-dotnet/issues/96

    2019 年 11 月 25 日更新: 服务器拒绝针对包含标头的 APNS 进行安装。现在这个问题已经解决,静默通知应该可以正常工作了。

    【讨论】:

      【解决方案2】:

      这个答案不准确,后台推送目前不适用于 azure。在发送推送期间需要包含标头,如下所示,并且集线器需要配置密钥而不是证书:

      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);
      

      【讨论】:

        猜你喜欢
        • 2015-01-21
        • 2019-12-25
        • 2019-09-28
        • 1970-01-01
        • 2020-01-25
        • 2021-03-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多