Question

I've integrated opentok ios sdk in my iOS 7 app, it is working fine, except this problem: During video chat if I don't access iPhone for 5-10 seconds..then my app moves into background, causing viewer at other end to hear only audio. Video is disabled after app goes to background state.

I've observed same thing with their official example https://github.com/opentok/opentok-ios-sdk/tree/master/samples/OpenTokFullTutorial

How can I avoid my app going to background while video chat is ongoing. Skype is working fine in this case, I want to achieve same thing.

Was it helpful?

Solution

What you want to do is prevent the iPhone from going to sleep. To do this, you cant try this:

[UIApplication sharedApplication].idleTimerDisabled = YES;

Here is iOS documentation on idleTimerDisabled

If you don't want the app going into background at all (like when the user taps on home button), you can opt to kill the app when it's not running instead of having it run in the background. To do that, check out iOS guide on opting out of background execution

If you do not want your app to run in the background at all, you can explicitly opt out of background by adding the UIApplicationExitsOnSuspend key (with the value YES) to your app’s Info.plist file. When an app opts out, it cycles between the not-running, inactive, and active states and never enters the background or suspended states. When the user presses the Home button to quit the app, the applicationWillTerminate: method of the app delegate is called and the app has approximately 5 seconds to clean up and exit before it is terminated and moved back to the not-running state.

Hope that helped!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top