Answer the question
In order to leave comments, you need to log in
VoIP socket for ios app?
There is an application that works in the background, I created a socket through a lib , I clearly let it know that it should work in the background, Everything should be fine, but after 15 minutes of work in the background, the socket is killed :(
Who has come across what can be done to make the socket did not close and continued to work.
Answer the question
In order to leave comments, you need to log in
- (void)backgroundHandler {
NSLog(@"### -->VOIP backgrounding callback");
UIApplication* app = [UIApplication sharedApplication];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
BOOL backgroundAccepted = [[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{ [self backgroundHandler]; }];
if (backgroundAccepted)
{
NSLog(@"VOIP backgrounding accepted");
}
UIApplication* app = [UIApplication sharedApplication];
bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
}];
}
I found a solution to the problem, added such code to the appDelegate and everything is working fine now in the background. There are few places where you can find a description of this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question