在后台模式下处理我的VoIP应用程序我使用的代码如下,它使我的voip App在后台进入时保持清醒状态,或者在后台进入后台时锁定电话,到达时,它会显示通知。我看到在IOS 8和更高版本setKeepAliveTimeout不再工作,我们需要使用Pushkit,有没有编码我们的服务器端使用pushKit?如何在后台应用程序中使用Pushkit与背景
- (void)registerKeepAliveHandler:(UIApplication*) application
{
LogInfo(TAG_MAIN, @"Registering KeepAliveTimeout");
[application setKeepAliveTimeout:600 handler:^{
[[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_KEEPALIVE_RECEIVED object:nil];
NSMutableString* statusStr = [[NSMutableString alloc] init];
switch ([[UIApplication sharedApplication] applicationState]) {
case UIApplicationStateActive:
[statusStr appendString:@"foreground"];
break;
case UIApplicationStateInactive:
[statusStr appendString:@"inactive"];
break;
case UIApplicationStateBackground:
[statusStr appendString:@"background"];
break;
default:
assert(0);
break;
}
LogInfo(TAG_MAIN, @"===================================== Keepalive received in %@ application status ===============================", statusStr);
[UIApplication getIPAddress];
LogInfo(TAG_MAIN, @"%@", [[UIDevice currentDevice] batteryInfo]);
[[SipEngine sharedInstance] isServerReachable];
[[SipEngine sharedInstance] isRegistered];
[[SipEngine sharedInstance] startStopRegistration];
[[[SipEngine sharedInstance] registration] registering];
}];
}
嗨@哈斯,谢谢。如果我想使用上面的函数,而不是NSLog(@“didReceiveIncomingPushWithPayload”);你有什么想法我需要使用?因为以这种方式它不起作用。 – Steven
欢迎@Steven,如果我的回答对你有帮助,那么你可以赞成并接受它。让我知道我是否可以随时帮助你。 – Hasya
你能接收Pushkit有效载荷吗?如果是的话,那么在pushkit有效载荷的基础上,您可以安排本地通知与来电的声音,也可以添加交互式事件来接受或拒绝call.https://github.com/hasyapanchasara/PushKit_SilentPushNotification/issues/1 – Hasya