I am trying to implement this (Configuring sockets to use VoIP) using this (CocoaAsyncSocket). As far as I know, step 1, which I did, adding VOIP to the background services in plist, and below should be step 2 (Configure one of the application sockets to use VoIP)
- (void)socket:(GCDAsyncSocket *)sock didConnectToHost:(NSString *)host port:(UInt16)connectedPort
{
[CCV setLocalMode:FALSE];
[socket performBlock:^{
[socket enableBackgroundingOnSocket];
}];
But I cannot understand the rest of the steps. If i do
- (void)applicationDidEnterBackground:(UIApplication *)application
{
expirationHandler = ^{
[app endBackgroundTask:bgTask];
bgTask = UIBackgroundTaskInvalid;
bgTask = [app beginBackgroundTaskWithExpirationHandler:expirationHandler];
};
bgTask = [app beginBackgroundTaskWithExpirationHandler:expirationHandler];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
while (1) {
sleep(1);
if ([rootViewController isIncomingCall] && showedCall != TRUE) {
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif) {
localNotif.alertBody = [NSString stringWithFormat:@"Incoming Call."];
localNotif.alertAction = NSLocalizedString(@"Accept Call", nil);
localNotif.soundName = @"alarmsound.caf";
[application presentLocalNotificationNow:localNotif];
[localNotif release];
}
showedCall = TRUE;
}
}
});
}
10 , . 2 : ( ) keepalive 5 . , . , apple " , VoIP-, , . , iOS setKeepAliveTimeout:handler: UIApplication" , - keepalive, , 600 ? , , , , , , .