2
votes

I am checking logs in xcode while application is in sleep mode. I am working with voip based application. I have done all the formalities regarding voip. I am able to keep app in sleep mode more than 20 mins. But after i disconnected device from system, i have run the app in sleep mode. Within 3-4 mins application gets crash. I have checked in device logs crashes. It is showing like

< BKProcessAssertion: 0x1463ab50 > id:xxx-xxx-xx... name: Called by SwyxOTT, from -[application enterIntoBackgroundState] process: < BKNewProcess: 0x14529680; com.aahlaad.SwyxiOSClient; pid: 289 > permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:289 preventSuspend preventIdleSleep preventSuspendOnSleep

I am using keepalive timeout function. You can see below function. I am using UDP connection, pjsip 2.2.1.

[self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES];
                [[UIApplication sharedApplication] setKeepAliveTimeout:KEEP_ALIVE_INTERVAL handler: ^{

[self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES];

                }];

Is any one knows regarding this issue please let me know.

2

2 Answers

2
votes

This crash is a result of calling -beginBackgroundTaskWithExpirationHandler: without a matching -endBackgroundTask:. At the very least, you should end the background task within the expiration handler, as such:

__block UIBackgroundTaskIdentifier backgroundTaskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
    [[UIApplication sharedApplication] endBackgroundTask:backgroundTaskID];
    backgroundTaskID = UIBackgroundTaskInvalid;
}];

Sources:

-1
votes

Try this.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [UIApplication sharedApplication].idleTimerDisabled=YES;
}