client :in plist file Required background modes:
[App plays audio or streams audio/video using AirPlay,App provides Voice over IP services]
in function createStream
CFReadStreamSetProperty(readStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);
CFWriteStreamSetProperty(writeStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeVoIP);
in function applicationDidEnterBackground
BOOL backgroundAccepted = [application setKeepAliveTimeout:600 handler:^{
[self send:[NSString stringWithFormat:@"%@ KeepAliveTimeout",[NSDate date]]];
}];
if (backgroundAccepted)
{
DLog(@"VOIP background");
}
_bgTaskId=[application beginBackgroundTaskWithExpirationHandler:^{
[self alert:@"ExpirationHandler"];
[application endBackgroundTask:_bgTaskId];
_bgTaskId=UIBackgroundTaskInvalid;
}];
in function applicationWillEnterForeground
[application clearKeepAliveTimeout];
server send message to client every 5 senconds with NSTimer.client app use local notification to show message in background immediately;