静默推送未传送到 iOS 11 上的应用程序 [英] Silent pushes not delivered to the app on iOS 11

查看:22
本文介绍了静默推送未传送到 iOS 11 上的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到在 iOS 11 beta 2 上,无论应用程序处于何种状态(后台/前台),静默通知都不会发送到 application:didReceiveRemoteNotification:fetchCompletionHandler.

我实现了 UIApplicationDelegete 方法 application:didReceiveRemoteNotification:fetchCompletionHandler 并发送以下静默推送

<代码>{aps":{内容可用":1},我的数据":{"foo": "酒吧"}}

但是在 iOS 11 上没有调用委托方法.

它适用于其他版本的 iOS 和文档部分

更新 14.08 - iOS 11 Beta 6

还是一样的行为.另一件应该有效但无效的事情是以下内容.当应用程序的方案设置为等待可执行文件启动"时,静默推送应该唤醒应用程序并在后台启动它.

更新 21.08 - iOS 11 Beta 7

仍然是相同的行为,而不是错误报告中来自 Apple 的更新.

更新 29.08 - iOS 11 Beta 8

还是一样的问题.我现在使用的重现步骤如下:

  • 在Xcode项目方案中,选择等待可执行文件启动"
  • didReceiveRemoteNotification中添加断点:fetchCompletionHandler
  • 在设备上启动应用
  • 发送上面的无声推送

预期:应用从挂起状态进入后台并调用didReceiveRemoteNotification: fetchCompletionHandler

实际:什么都没有发生

更新 06.09 - iOS 11 Beta 10

我仍然有同样的错误行为.来自 Apple 的票已更新为以下答案:

<块引用>

Apple Developer Relations 2017 年 9 月 6 日晚上 10:42提供了有关此问题的以下反馈:

我们能够运行示例应用并测试其行为.我们当我们按照描述进行测试时,没有发现任何问题.

在应用程序运行时不保证推送到达背景和这里的日志表明我们不相信该应用程序是被用来启动它.

我们确实看到我们在条件合适时不时提供推送好的.

我们认为这是正确的.

更新 11.09

我的 Apple 错误报告已关闭并标记为 33278611 的副本,但仍处于打开状态

更新 13.09 - iOS 11 GM

感谢 kam800 的评论(见下文),我进行了更多测试并得出了这些观察结果:

iOS 11 中似乎有一个新的守护进程 dasd DuetActivitySchedulerDaemon 要么完全丢弃数据推送要么延迟数据推送交付:

延迟交货

控制台日志

default 13:11:47.177547 +0200 dasd DuetActivitySchedulerDaemon CANCELED: com.apple.pushLaunch.net.tequilaapps.daylight:C03A65 !生命周期 com.apple.duetactivityscheduler默认 13:11:47.178186 +0200 dasd DuetActivitySchedulerDaemon 删除应用程序 <private> 的启动请求按活动 <private>默认 com.apple.duetactivityscheduler默认 12:49:04.426256 +0200 dasd DuetActivitySchedulerDaemon 推进 <private> 的开始日期6.5 分钟到 2017 年 9 月 13 日星期三 12:55:31 默认 com.apple.duetactivityscheduler默认 13:21:40.593012 +0200 dasd DuetActivitySchedulerDaemon Activity <private>:在 <private> 的最佳得分 0.6144(有效期至:<private>)评分 com.apple.duetactivityschedulerdefault 13:21:40.594528 +0200 dasd DuetActivitySchedulerDaemon 在 <private> 之间设置计时器(isWaking=1,activityRequiresWaking=0)和<私人>为<私人>默认 com.apple.duetactivityscheduler

延期交货问题

  • 当数据推送延迟并启动应用程序时,数据推送仅在到达交付日期时交付,可能是几分钟.这完全违背了使用数据推送来保持新应用程序的内容为下一次发布做好准备的目的.我在这里再次引用 Apple 的文档:
<块引用>

无提示通知通过帮助您保持您的应用是最新的,即使它没有运行."

  • 两次数据推送被发送到暂停的应用程序时,它们会被 iOS 11 推迟,而不是直接唤醒应用程序.当到达交付时间时,只交付最后一个数据推送!之前的推送丢失且未通过委托方法传送,从而导致数据丢失.

配送取消

控制台日志

default 13:35:05.347078 +0200 dasd DuetActivitySchedulerDaemon com.apple.pushLaunch.net.tequilaapps.daylight:C03A65:[{name: ApplicationPolicy, policyWeight: 50.000, response: {Decision: Must Not Proceed, Score: 0.00}}], FinalDecision: Must Not Proceed}计分com.apple.duetactivityscheduler

取消递送问题

好吧,在这种情况下,数据推送完全丢失并且从未在 iOS 11 上交付,而在 iOS 10 上正确交付.

更新 19.09 - iOS 11 GM

我还注意到,当应用程序在前台并且通知没有传递到应用程序时,我在控制台中看到以下日志:

default 08:28:49.354824 +0200 apsd apsd <private>:接收到启用主题<private>"的消息onInterface:具有有效载荷<private>"的非蜂窝设备令牌的优先级为 10:NO courier-oversized com.apple.apsd故障 08:33:18.128209 +0200 dasd Foundation <NSXPCConnection: 0x151eee460>来自 pid 55 的连接:在接收消息解码期间捕获异常,丢弃传入消息.异常:解码参数 0 时出现异常(调用的 #2):例外:键NS.objects"的值属于意外的NSNull"类.允许的类是 '{(NSArray,NSData,NSString,NS号码,NSD词典,NSUUID,_DAS活动,NSSet,_DAS 文件保护,NSDate,NW 参数,西北端点)}'.一般com.apple.foundation.xpc

解决方案

iOS 11.1 beta 1 的发行说明这样说

<块引用>

iOS 11.1 beta 1 刚刚发布,他们提到:"通知已解决的问题• 更频繁地处理静默推送通知.(33278611)

我做了一些测试,似乎确实修复了:

暂停状态

当我以暂停模式启动应用程序并发送静默推送时,应用程序将返回后台并调用 didReceiveRemoteNotification:fetchCompletionHandler 委托.

前台状态

同样的,当应用程序在前台并且发送一个静默推送时,委托似乎是按预期调用的.这在之前的 iOS 11 版本中随机不起作用,所以我会在更多测试后确认这一点.

I noticed that on iOS 11 beta 2, the silent notifications are not delivered to the application:didReceiveRemoteNotification:fetchCompletionHandler regardless the state of the app (background / foreground).

I implemented the UIApplicationDelegete method application:didReceiveRemoteNotification:fetchCompletionHandler and I send the following silent push

{  
  "aps": {  
    "content-available": 1  
  },  
  "mydata": {  
    "foo": "bar"  
  }  
} 

but the delegate method is not called on iOS 11.

It works fine on other versions of iOS and the documentation section Configuring a Silent Notification does not mention that anything else should be done.

Is this a bug in iOS 11 or did I miss something new in iOS 11?

Please note that I'm not talking about or using the UserNotification framework which should not be needed for sending silent pushes.

Here is a sample project that illustrates the issue (you'll have to set your own bundle id)

When you lunch the sample project and send a above payload to the app, you can use the macOS console to see that the push is correctly delivered to the device but not to the app.

UPDATE 10.08

It appears that the behaviour is random. Sometimes after restarting the device, the payload is delivered correctly but it stops working after a while.

As you can see on the following screenshot, the push marked as 1 is delievered only to the device and the push 2 (after device restart) is also delivered to the app.

UPDATE 14.08 - iOS 11 Beta 6

Still the same behaviour. Another thing that is supposed to work but does not is the following. When the application's scheme is set to "Wait for executable to be launched", a silent push is supposed to wake up the app and start it in background.

UPDATE 21.08 - iOS 11 Beta 7

Still the same behaviour and not updates from Apple in the bug report.

UPDATE 29.08 - iOS 11 Beta 8

Still the same problem. The steps to reproduce I use now are the following:

  • In the Xcode project scheme, select "Wait for executable to be launched"
  • Add a breakpoint in the didReceiveRemoteNotification: fetchCompletionHandler
  • Start the app on device
  • Send the above silent push

Expected: The app is brought from suspended state to background and the didReceiveRemoteNotification: fetchCompletionHandler is called

Actual: nothing happens

UPDATE 06.09 - iOS 11 Beta 10

I'm still having the same buggy behaviour. The ticket from Apple was updated with the following answer:

Apple Developer Relations September 6 2017, 10:42 PM Engineering has provided the following feedback regarding this issue:

We were able to get the sample app running and test the behavior. We didn’t see any issues when we tested this as described.

Pushes aren't guaranteed to arrive to the app when it is running in the background, and the logs here indicate we don't believe the app is being used enough to launch it.

We do see us delivering pushes from time to time when conditions are good.

We believe this is behaving correctly.

Update 11.09

My Apple bug report was closed and marked as duplicate of 33278611 which remains open

UPDATE 13.09 - iOS 11 GM

Thanks to kam800's comments (see below) I did more testing and came up with those observations:

There seem to be a new daemon in iOS 11 dasd DuetActivitySchedulerDaemon that either completely discards the data push or delays the data push delivery:

Delivery postponed

Console Logs

default 13:11:47.177547 +0200   dasd    DuetActivitySchedulerDaemon CANCELED: com.apple.pushLaunch.net.tequilaapps.daylight:C03A65 <private>!   lifecycle   com.apple.duetactivityscheduler
default 13:11:47.178186 +0200   dasd    DuetActivitySchedulerDaemon Removing a launch request for application <private> by activity <private>   default com.apple.duetactivityscheduler
default 12:49:04.426256 +0200   dasd    DuetActivitySchedulerDaemon Advancing start date for <private> by 6.5 minutes to Wed Sep 13 12:55:31 2017   default com.apple.duetactivityscheduler
default 13:21:40.593012 +0200   dasd    DuetActivitySchedulerDaemon Activity <private>: Optimal Score 0.6144 at <private> (Valid Until: <private>)  scoring com.apple.duetactivityscheduler
default 13:21:40.594528 +0200   dasd    DuetActivitySchedulerDaemon Setting timer (isWaking=1, activityRequiresWaking=0) between <private> and <private> for <private>  default com.apple.duetactivityscheduler

Postponed delivery issues

  • When the data push delivery is postponed and the app is launched, the data push is delivered only when the delivery date is reached which can be several minutes in the future. This defeats completely the purpose of using data pushes to keep the new app's content ready for the next launch. I quote here once again Apple's documentation:

"Silent notifications improve the user experience by helping you keep your app up-to-date, even when it is not running."

  • When two data pushes are sent to a suspended app they are postponed by iOS 11 instead of waking up the app directly. When delivery time is reached, only the last data push is delivered! The previous pushes are lost and not delivered via the delegate method resulting in a data loss.

Delivery cancelled

Console Logs

default 13:35:05.347078 +0200   dasd    DuetActivitySchedulerDaemon com.apple.pushLaunch.net.tequilaapps.daylight:C03A65:[
    {name: ApplicationPolicy, policyWeight: 50.000, response: {Decision: Must Not Proceed, Score: 0.00}}
 ], FinalDecision: Must Not Proceed}    scoring com.apple.duetactivityscheduler

Cancelled delivery issues

Well in this case, the data push is completely lost and never delivered on iOS 11 while it was delivered correctly on iOS 10.

UPDATE 19.09 - iOS 11 GM

I also noticed that when the application is in the foreground and the notification is not delivered to the app, I see the following logs in the console:

default 08:28:49.354824 +0200   apsd    apsd    <private>: Received message for enabled topic '<private>' onInterface: NonCellular with payload '<private>' with priority 10 for device token: NO   courier-oversized   com.apple.apsd

fault   08:33:18.128209 +0200   dasd    Foundation  <NSXPCConnection: 0x151eee460> connection from pid 55: Exception caught during decoding of received message, dropping incoming message.
Exception: Exception while decoding argument 0 (#2 of invocation):
Exception: value for key 'NS.objects' was of unexpected class 'NSNull'. Allowed classes are '{(
    NSArray,
    NSData,
    NSString,
    NSNumber,
    NSDictionary,
    NSUUID,
    _DASActivity,
    NSSet,
    _DASFileProtection,
    NSDate,
    NWParameters,
    NWEndpoint
)}'.    general com.apple.foundation.xpc

解决方案

So the release notes of iOS 11.1 beta 1 say

iOS 11.1 beta 1 was just released and they mention: "Notifications Resolved Issues • Silent push notifications are processed more frequently. (33278611)

I did some tests and it seems to be indeed fixed:

Suspended State

When I launch the app in a suspended mode and send a silent push, the app is brought back to background and the didReceiveRemoteNotification:fetchCompletionHandler delegate is called.

Foreground State

In the same way, when the application is in foreground and a silent push is sent, the delegate seems to be called as expected. This was randomly not working in previous iOS 11 versions so I will confirm this after more testing.

这篇关于静默推送未传送到 iOS 11 上的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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