【发布时间】:2014-04-29 12:32:45
【问题描述】:
最近我必须使用 voip 实现后台工作应用程序。为此,我使用 PJSip。 现在,当应用程序运行时,我已经完成了注册和处理呼叫。
当应用程序进入后台时,前 10 分钟工作正常 -> 新来电被捕获并作为本地通知发送 - 所以这很好。 10 分钟后,sip 停止工作并且来电也没有到达。
你能帮我解决这个问题吗?
我已检查“免费工作 - VoiP” 我已经通过 siphon2 示例应用程序在 pjsip 中保持活动状态。
我也有:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[[PjSipService service] setIsInBackground:YES];
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
int KEEP_ALIVE_INTERVAL = 600;
[self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES];
NSLog(@"startingKeepAliveTimeout1");
[application setKeepAliveTimeout:KEEP_ALIVE_INTERVAL handler: ^{
NSLog(@"startingKeepAliveTimeout2");
[self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES];
}];
__block UIBackgroundTaskIdentifier bgTask;
bgTask = [application beginBackgroundTaskWithExpirationHandler:^{
[application endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//[self deregis];
[application endBackgroundTask: bgTask]; //End the task so the system knows that you are done with what you need to perform
bgTask = UIBackgroundTaskInvalid; //Invalidate the background_task
NSLog(@"\n\nRunning in the background!\n\n");
});
}
“keepAlive”函数为空。 我已经读过这个功能keepAlive就足够了 - 但是没有后台任务它甚至不能工作10分钟。
应用程序必须在 iOS7 和 iOS6 中运行
【问题讨论】:
标签: ios backgroundworker pjsip