Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如果强制退出应用程序并重新启动设备,Voip Pushkit通知将不会重新启动该应用程序_Ios_Ios8_Notifications_Apple Push Notifications_Voip - Fatal编程技术网

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

Ios 如果强制退出应用程序并重新启动设备,Voip Pushkit通知将不会重新启动该应用程序,ios,ios8,notifications,apple-push-notifications,voip,Ios,Ios8,Notifications,Apple Push Notifications,Voip,如果用户已强制退出应用程序(通过在多任务界面中向上滑动),并且设备已重新启动,则我无法获取重新启动应用程序的voip pushkit通知 但是,我可以让voip pushkit通知在以下场景中工作: 应用程序被强制退出,然后pushkit通知到达。应用程序将立即重新启动。在这种情况下,标准推送通知无法唤醒应用程序 应用程序处于后台/已挂起,设备已重新启动。多亏了Voip模式,该应用程序将在设备重新启动时重新启动(我可以在Xcode活动监视器中看到该过程)。这里需要一个技巧来正确处理pushki

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

但是,我可以让voip pushkit通知在以下场景中工作:

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

  • 应用程序处于后台/已挂起,设备已重新启动。多亏了Voip模式,该应用程序将在设备重新启动时重新启动(我可以在Xcode活动监视器中看到该过程)。这里需要一个技巧来正确处理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)重新启动。应用程序将不会重新启动,新的推送通知仍不会重新启动。

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

操作系统显然以不同的方式处理开发和生产

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

:XXXX-XX-XX XX:XX:XX+0300 apsd[97]:
已删除这些启用的主题{( “您的\u BUNLE\u标识符” )}


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

@sahara108和我自己也有这个问题。我直接问过苹果,所以如果他们在别人弄明白之前回答,我会把答案贴在这里。您还提到WhatsApp等人可以重新启动,但他们是否完全重新启动?在我们的调查中,应用程序会重新启动,但不会完全启动。他们的日志被提前截断(看起来像是操作系统死机)。我通过查看活动监视器中正在启动的进程来确定应用程序已重新启动。您是指appstore设置吗?在我的测试中,该应用程序能够在手机重新启动时重新启动,但不完整。它在尝试打开xmpp套接字连接时被卡住。目前网络似乎不可用。你的应用程序能否成功重新启动?