如果强制退出并重启设备,Voip Pushkit 通知将不会重新启动应用程序

Voip Pushkit notification will not re-launch the app if it was force-quitted and device was rebooted

如果用户强行退出应用程序(通过在多任务界面中向上滑动)并且设备已重启,我无法收到 voip pushkit 通知以重新启动应用程序。

但是,我可以在以下情况下使用 voip 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 ...
}

我还在后台模式中启用了 "Voice over IP" 和 "Remote notifications"。

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

在相关说明中,执行以下操作没有帮助 1) 强制退出 2) 发送 pushkit 通知 - 将收到 3) 重新启动。该应用程序不会重新启动,并且新的推送通知仍然不会重新启动它。

在我使用 AdHoc 配置文件测试应用程序(并从 iTunes 安装它)后,通过 prod gateway.push.apple.com 而不是 gateway.sandbox.push.apple.com 提供的 Voip 推送通知开始唤醒强制退出的应用程序重启后。

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

进一步查看 APSD 日志,我发现在使用开发配置文件时打印出以下内容:

: XXXX-XX-XX XX:XX:XX +0300 apsd[97]:
These enabled topics have been removed {( "YOUR_BUNLE_IDENTIFIER" )}

使用临时配置文件时不会发生这种情况。