【问题标题】:Voip Pushkit notification will not re-launch the app if it was force-quitted and device was rebooted如果应用程序被强制退出并且设备重新启动,Voip Pushkit 通知将不会重新启动应用程序
【发布时间】:2015-09-16 08:28:12
【问题描述】:

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

但是,我可以让 voip pushkit 通知在以下情况下工作:

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

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

【问题讨论】:

  • @sahara108 和我自己也有这个问题。我已经直接问过苹果,所以如果他们在其他人弄清楚之前回答,我会在这里发布答案。您还提到您的 WhatsApp 等可以重新启动,但它们会完全重新启动吗?在我们的调查中,应用程序重新启动但没有完全启动。他们的日志记录被过早地截断(看起来像是操作系统被杀)。
  • 通过查看活动监视器中正在启动的进程,我确定应用程序已重新启动。

标签: ios ios8 notifications apple-push-notifications voip


【解决方案1】:

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

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

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

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

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

【讨论】:

  • 您的意思是应用商店配置吗?在我的测试中,当手机重新启动但不完整时,该应用程序能够重新启动。尝试打开 xmpp 套接字连接时卡住了。看来此时网络不可用。您的应用能否成功重新启动?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-11
  • 2015-08-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多