VOIP Pushkit通知将不会重新启动应用程序,如果它是力脱党与器件重新启动 [英] Voip Pushkit notification will not re-launch the app if it was force-quitted and device was rebooted
问题描述
我不能让用户是否具有强制离开了应用程序(在多任务界面刷卡它)VOIP pushkit通知重新启动应用程序,如果设备被重新启动。
I cannot get voip pushkit notifications to re-launch the app if the user has force-quitted the app (by swiping it up in the multi-tasking interface) AND if the device was rebooted.
不过,我可以得到VOIP pushkit通知在下列情况下工作:
However, I can get the voip pushkit notifications to work in the following scenarios:
-
该应用程序是力辞去则pushkit通知到达。该应用程序将立即重新启动。标准推送通知不能够醒来在这样的场景的应用程序。
The app was force-quitted then the pushkit notification arrives. The app will be relaunched immediately. Standard push notifications are not capable of waking the app in such scenario.
该应用程序在后台/暂停,设备将重新启动。由于到VoIP模式,应用程序将在重启设备来重新启动(我可以看到在X code活性监控过程中)。有它在<一的描述进行适当的处理在这里得到pushkit通知需要一招href=\"http://blog.biokoda.com/post/114315188985/ios-and-pushkit\">http://blog.biokoda.com/post/114315188985/ios-and-pushkit在这些条款初始化PushKit之前启动一个后台任务。完成时PushKit令牌接到这个任务
The app was in the background / suspended and the device is rebooted. Thanks to Voip mode, the app will be relaunched on device reboot (I can see the process in Xcode Activity Monitor). There is a trick needed here to get the pushkit notification to be properly processed which is described in http://blog.biokoda.com/post/114315188985/ios-and-pushkit in these terms "Before initializing PushKit start a background task. Finish this task when PushKit token is received"
不知怎的,结合这两种(设备重新启动,并应用程序强制退出),然后pushkit通知时似乎并没有重新启动应用程序。也期待在X code中的设备日志,当我从APSD称通知没有日志已被系统处理。
Somehow when combining these two (device reboot AND app force-quit) then pushkit notifications doesn't seem to relaunch the app. Also when looking at the device logs in Xcode I get no logs from apsd saying the notification was processed by the system.
下面是我的code:
@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语音和远程通知,在后台模式下启用。
Also I have "Voice over IP" and "Remote notifications" enabled in Background modes.
我知道其他应用例如WhatsApp能够在这种情况下重新启动正,所以我不明白我做错了。
I know other apps like Whatsapp are capable of being relaunched in this scenario, so I don't understand what I am doing wrong.
在一个相关的说明,它不利于做到以下几点1)强制退出2)发送pushkit通知 - 将收到3)重新启动。该应用程序将不会重新启动一个新的推送通知仍然不会重新启动它。
On a related note, it doesn't help to do the following 1) Force quit 2) Send a pushkit notification - which will be received 3) Reboot. The app will not be relaunched and a new push notification will still not relaunch it.
推荐答案
在我测试了即席调配配置文件的应用程序(和从iTunes安装),VoIP的推送通知通过督促担任gateway.push.apple.com代替gateway.sandbox.push.apple.com的开始重启后醒来的力辞去应用程序。
After I tested the app with an AdHoc provisioning profile (and installed it from iTunes), the Voip push notifications served through prod gateway.push.apple.com instead of gateway.sandbox.push.apple.com started waking up the force-quitted app after reboot.
操作系统显然是处理开发和生产以不同的方式。
The os is apparently handling development and production in a different manner.
展望进一步进入APSD日志,我发现使用开发配置文件以下时打印出来:
Looking further into the APSD logs, I found that when using a development provisioning profile the following is printed out:
:XXXX-XX-XX XX:XX:XX 0300 APSD [97]:搜索
这些已启用的主题已被删除{(
YOUR_BUNLE_IDENTIFIER
)}
: XXXX-XX-XX XX:XX:XX +0300 apsd[97]:
These enabled topics have been removed {( "YOUR_BUNLE_IDENTIFIER" )}
使用即席供应配置文件时,这不会发生。
This does not happen when using an adhoc provisioning profile.
这篇关于VOIP Pushkit通知将不会重新启动应用程序,如果它是力脱党与器件重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!