我试图定期在我的应用程序中实现Silent Push Notification
,即每天一次将数据上传到服务器。但是在 iOS上 11.2.6 上,它始终无法调用委托(delegate)方法
-(void) application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))
静默推送通知的
completionHandler
。在设备日志中,我可以看到收到静默推送通知,但是
DuetActivitySchedulerDaemon
取消了应用程序启动(根据日志)。您能帮我解决这个问题吗?以下是设备的日志。
Apr 11 21:44:59 iPhone- SpringBoard(UserNotificationsServer)[2696] <Notice>: [com.***.***-myapp] Received remote notification request 91E8-DC24 [ hasAlertContent: 0, hasSound: 0 hasBadge: 0 hasContentAvailable: 1 hasMutableContent: 0 ]
Apr 11 21:44:59 iPhone- SpringBoard(UserNotificationsServer)[2696] <Notice>: [com.***.***-myapp] Deliver push notification request 91E8-DC24.
Apr 11 21:44:59 iPhone- SpringBoard(UserNotificationsServer)[2696] <Notice>: [com.***.***-myapp] Passing content-available push to Duet.
Apr 11 21:44:59 iPhone- SpringBoard(DuetActivityScheduler)[2696] <Notice>: SUBMITTING: <private>.
Apr 11 21:44:59 iPhone- SpringBoard(UserNotificationsServer)[2696] <Error>: Ignoring notification with no alert, sound or badge (com.***.***-myapp): 91E8-DC24
Apr 11 21:44:59 iPhone- SpringBoard(UserNotificationsServer)[2696] <Notice>: [com.***.***-myapp] Not saving push notification 91E8-DC24 to store [ error=Error Domain=UNErrorDomain Code=1401 "Notification has no user-facing content" UserInfo={NSLocalizedDescription=Notification has no user-facing content} ]
Apr 11 21:44:59 iPhone- dasd(DuetActivitySchedulerDaemon)[163] <Notice>: Submitted Activity: com.apple.pushLaunch.com.***.***-myapp:88F855 <private>
Apr 11 21:44:59 iPhone- dasd(DuetActivitySchedulerDaemon)[163] <Notice>: Daemon Canceling Activities: {(
com.apple.pushLaunch.com.***.***-myapp:88F855 )}
Apr 11 21:44:59 iPhone- dasd(DuetActivitySchedulerDaemon)[163] <Notice>: CANCELED: com.apple.pushLaunch.com.***.***-myapp:88F855 <private>!
它确实可以在其他操作系统上工作一段时间,并且会完全停止,直到下次启动为止。
最佳答案
没有什么要解决的。这是预期的行为。
自从WWDC13以来,人们一直很清楚,后台事件将仅限于实际使用的应用程序。可以通过pre 11之前的静默推送来绕过此限制,但一如既往,它成为常见的滥用行为。实际上,令dasd在以前的版本中没有更具侵略性的事实感到惊讶。