how to keep ios app using opentok video chat in foreground - objective-c

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.

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!

Related

iBeacon detection wake up iPhone from sleep mode with UILocalNotification

My application run on iOS 8 and when it go into background it need to detect and show a notification to the user when iBeacon detected (with UILocalNotification).
All works fine but when the iPhone is sleep/locked the Notification doesn't wake up the device.
How can I wake up the device when a notification come in?
Make sure the phone is detecting the beacon at all. Try adding a NSLog statement inside the didEnterRegion method or wherever you launch the notification. Then, start looking at the debug console while the phone screen is off and turn on the beacon. Do you get a debug line?
If you do not see the debug line, the issue is with detection, not with the notification. Note that it can take up to 15 minutes on an iPhone 4S to detect a beacon.
If this does not help, please post your code that sets up region monitoring and sends the notification. Also, please, describe how you are testing entering and exiting the region.

can I run movie player in background when mirroring to external screen - objective c

I have an application that plays video from local disk and when a second screen is connected (through AV composite cable) it switch the movie view to the external screen. this is working fine so far. what I want is, when the user press the home button and the app goes to background mode; I want to continue playing the video in the second screen while the app is running in the background mode. this works for audio, as I have set my application to continue play audio in background mode and it is working fine: the audio continue to play in the background mode fine. now is it possible to continue play video as well, and how?
This is not possible. It is outside of the scope of an iOS app to continue powering a screen while it is in the background.

Lock screen wallpaper without audio playing in background iphone

I am working on application in which i have to change the lock screen wallpaper without playing audio in background through application programmatically. I have done with audio in background but is there any way i can do through application. There is an app on appstore here is the link https://itunes.apple.com/us/app/sticky-notes-hd-with-bump/id364874025?mt=8 I dont know how it is possible.
Thanks.

How do I play an alarm sound and present a custom view instead of just a notification?

I'm working on an alarm clock application for iOS 4.x. The other alarm clock applications that I've seen are able to present the user with something other than a local notification (i.e., a custom view) and are able to play a sound file. I've been looking into how that's done and have only found this solution:
Play sound with screen turned off / don't let iPhone go to sleep
Is there another approach or is this the best practice?
When your app is not visible, you can't display anything. The silent sound workaround is a cool trick but when a user presses your home button, your app is not visible (and might get destroyed under certain conditions) -> therefore you can't display anything.
So if you tell your user to use your alarm clock by firing it up and then press the sleep button it will work - you can display anything on your screen after the user unlocks the iphone again.
Needless to say that playing sound (even silent sound files) drains the battery so your user might be disappointed if he's not woken up because his iphone has run out of battery.
And yes, there is best practice: Local Notifications! Beginning with iOS 5 it will display your apps icon next to the notification...

iOS Multitasking App Launch

I developed an app for IPhone and it's posted to itunes for approval. Now when I test the app I found out a strange behavior which I think should be rectified. When I launch app first time, the app launched and when I press home button it closes but when I tap the app icon to open it again it opens where it was last closed.
How can I change the view to first view of the app when it's launched after closing by Home screen button?
If you don't want your app to run in the background you need to set the "Application does not run in background" key in the info.plist file. This means that your app will completely restart every time your user returns to it. Take time to decide if this really is the best move for your app. Allowing users to return to where they left off or remembering information about the last session can be a big plus.
If you do not set the info.plist value like I mention above you can manage the way your app behaves by using the: applicationWillEnterForeground: in UIApplicationDelegate or you could observe UIApplicationWillEnterForegroundNotifications. Read up on all the available notifications and methods available for this in the UIApplication Delegate documentation.