I am using this code for enabling background mode for my VOIP application.
- (void)applicationDidEnterBackground:(UIApplication *)application{
[NSTimer timerWithTimeInterval:60.0 target:self selector:@selector(sipRegisterEveryTime) userInfo:nil repeats:YES];
[self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES];
[application setKeepAliveTimeout:KEEP_ALIVE_INTERVAL handler:
^{
[self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES];
}];}
And Code for KeepAlive is :
- (void)keepAlive{
int i;
if (!pj_thread_is_registered())
{
pj_thread_register("ipjsua", a_thread_desc, &a_thread);
}
/* Since iOS requires that the minimum keep alive interval is 600s, * application needs to make sure that the account's registration
* timeout is long enough. */
for (i = 0; i < (int)pjsua_acc_get_count(); ++i)
{
if (pjsua_acc_is_valid(i))
{
pjsua_acc_set_registration(i, PJ_TRUE);
}
}
pj_thread_sleep(15000);}
But I am not getting my app to awake if any VOIP call is arrived while my app is in background. info.plist have settings enabled for VOIP background by setting "App provides Voice over IP services" inside "Required background modes" Inside capabilities settings for VOIP is done. Is there any additional thing I need to do? I am using PJSIP library for my VOIP app.