Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use setKeepAliveTimeout:handler - IOS?

We are working on an VoIP application, when my application goes background, I have been trying to use the setKeepAliveTimeout:handler: to keep the connection alive. As per the apple documentation, they asks to give minimum 600 seconds as timeout. Actually we are maintaining less timeout value, is it possible to handle with less time out?

And if the time out hits, how to use the handler to reset the timer or request more time so that I can keep my connection alway alive (to receive incoming calls)?

Here is what I am doing...

- (void)applicationDidEnterBackground:(UIApplication *)application
{

    BOOL backgroundAccepted = [[UIApplication sharedApplication] setKeepAliveTimeout:600 handler:^{ [self backgroundHandler]; }];
    if (backgroundAccepted)
    {
        NSLog(@"VOIP backgrounding accepted");
    }
}




- (void)backgroundHandler {

    NSLog(@"### -->VOIP backgrounding callback"); // What to do here to extend timeout?
}
like image 336
Newbee Avatar asked Nov 03 '22 03:11

Newbee


1 Answers

From Apple's documentation:

The minimum acceptable timeout value is 600 seconds.

EDIT regarding your comment

A VoIP connection is an (almost) normal connection. I.e., if your have incomming data, your app resumes execution in the background. The timeout handler is for the case that you want to ping the other side to avoid timeout there. A bit more information gives TN 2277.

like image 118
Matthias Avatar answered Nov 10 '22 08:11

Matthias