My app has just been rejected by Apple as it does not properly implement background running and it is a VOIP app using iOS.
My odd code that kept it running was
[self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES];
[application setKeepAliveTimeout:KEEP_ALIVE_INTERVAL handler: ^{
[self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES];
}];
Which I know is wrong
I then followed the
http://blog.dkaminsky.info/2013/01/27/keep-your-ios-app-running-in-background-forever/ which is the VOIP hack to get it running all the time. Again I think this is wrong.
I basically just need to call one method to keep PJSIP alive.
How should I do this properly?
UPDATE
I have looked at the Apple guide, it appears this is correct
[application setKeepAliveTimeout:KEEP_ALIVE_INTERVAL handler: ^{
[self performSelectorOnMainThread:@selector(keepAlive) withObject:nil waitUntilDone:YES];
NSLog(@"Fire");
}];
However I am not sure how to configure PJSIP TCP port to run in the background.
APPLE : Configure one of the app’s sockets for VoIP usage.
The runs fine in the background its just Apple rejecting it
2.16
We found that your app uses a background mode but does not include functionality that requires that mode to run persistently. This behavior is not in compliance with the App Store Review Guidelines.
We noticed your app declares support for VoIP in the UIBackgroundModes key in your Info.plist but does not support incoming calls from the connected VoIP service.
If your application does not support incoming calls from it's connected VoIP service, the voip background mode is not appropriate. As indicated in the iOS Programming Guide, this key is for applications that need to monitor sockets for incoming calls:
"Rather than keep VoIP apps awake all the time, the system allows them to be suspended and provides facilities for monitoring their sockets for them. When incoming traffic is detected, the system wakes up the VoIP app and returns control of its sockets to it."
Please look into using the "audio" value in the UIBackgroundModes key of your Info.plist file. Using the audio background mode will keep current out-going VoIP calls open while your app is in the background.
It would be appropriate to add VoIP features or remove the "VoIP" setting from the UIBackgroundModes key.For discrete code-level questions, you may wish to consult with Apple Developer Technical Support. Please be sure to:
Update 2
PJSIP has told me that the sockets are marked for VOIP and so I have no idea why this is being rejected