Recently I have to implement background working app with voip. For that I use PJSip. Right now I have done registering and handling calls working perfectly when app is running.
When app goes to the background, by first 10 minuts works fine -> new incomming calls are captured and are send as local notifications - so this is fine. After 10 minutes sip stops working and incomming calls doesn't arrives as well.
Could you help me with this?
I have check "bacground working - VoiP" I have done keep alive in pjsip from siphon2 example application.
I have also:
- (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" function is empty. I've read that for this function keepAlive is enought - but without background task it doesn't work even 10 minuts.
Application has to works in iOS7 and iOS6