Newbee
Newbee

Reputation: 3301

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?
}

Upvotes: 5

Views: 5804

Answers (1)

Matthias
Matthias

Reputation: 8180

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.

Upvotes: 2

Related Questions