Voip Pushkit通知将不会重新启动应用程序,如果它是强行离开和设备重新启动

如果用户强行退出了应用程序(通过在多任务界面中刷卡),并且设备重新启动,我无法获取voip pushkit通知以重新启动应用程序。

但是,我可以使voip pushkit通知在以下情况下运行:

  • 该应用程序是强制退出,然后pushkit通知到达。 该应用程序将立即重新启动。 标准推送通知不能在这种情况下唤醒应用程序。

  • 该应用程序在后台/暂停和设备重新启动。 由于Voip模式,应用程序将重新启动设备(我可以看到在Xcode活动监视器的过程)。 这里需要一个技巧来获得pushkit通知的正确处理,在http://blog.biokoda.com/post/114315188985/ios-and-pushkit中描述了这些术语:“在初始化PushKit之前开始一个后台任务。当收到PushKit令牌时完成此任务“

不知何故,当这两个(设备重新启动和应用程序强制退出),然后pushkit通知似乎不会重新启动应用程序。 另外,当查看Xcode中的设备日志时,我没有从apsd获得日志,表示通知是由系统处理的。

这是我的代码:

@implementation AppDelegate { UIBackgroundTaskIdentifier bgTask; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UIApplication* app = [UIApplication sharedApplication]; bgTask = [app beginBackgroundTaskWithExpirationHandler:^{ [app endBackgroundTask:bgTask]; bgTask = UIBackgroundTaskInvalid; }]; dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ while (true) { ; } }); // Initialize pushkit PKPushRegistry *pushRegistry = [[PKPushRegistry alloc] initWithQueue:dispatch_get_main_queue()]; pushRegistry.delegate = self; pushRegistry.desiredPushTypes = [NSSet setWithObject:PKPushTypeVoIP]; return YES; } - (void)pushRegistry:(PKPushRegistry *)registry didUpdatePushCredentials:(PKPushCredentials *)credentials forType:(NSString *)type{ UIApplication* app = [UIApplication sharedApplication]; [app endBackgroundTask:bgTask]; // ... more code to read the token ... } - (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(NSString *)type { // ... logging to check if notification is received ... } 

此外,我还在背景模式下启用了“IP语音”和“远程通知”。

我知道Whatsapp等其他应用程序可以在这种情况下重新启动,所以我不明白我做错了什么。

在相关的说明,它不帮助做以下1)强制退出2)发送pushkit通知 – 将收到3)重新启动。 该应用程序不会重新启动,新的推送通知将不会重新启动它。

在我使用AdHoc供应configuration文件(并从iTunes安装它)testing应用程序之后,通过prod gateway.push.apple.com而不是gateway.sandbox.push.apple.com服务的Voip推送通知开始唤醒撤销应用程序重启后。

os显然是以不同的方式处理开发和生产。

仔细查看APSD日志,我发现在使用开发configuration文件时,打印出以下内容:

:XXXX-XX-XX XX:XX:XX +0300 apsd [97]:
这些启用的主题已被移除{(“YOUR_BUNLE_IDENTIFIER”)}

使用adhocconfiguration文件时不会发生这种情况。