UIApplicationExitsOnSuspend and screen refresh - ios

I have an app that has the UIApplicationExitsOnSuspend info list property set to TRUE.
And now I am noticing a curious issue.
I start up the app and let it run on my phone and do not touch my phone. Eventually the phone screen goes dark and the phone goes into standby mode. When I wake the phone up, what I see is a screenshot of the last screen displayed on the app. (This seems according to spec, since the Apple documentation says that in the process of moving an app to the background, ios takes a picture of the app and uses that for transitions when the app comes back to life). If I double click on the home button to see running apps, I do not see an instance of the app running. (again, working as intended since UIApplicationExitsOnSuspend is set to true).
My question is, how do I make sure that when the phone wakes up, it comes back to the default home screen and not the picture of the app ? Clearly the app is not running on waking up, so there is nothing I can do from within the app that will refresh the screen. I could try to exit when the app is going to background, but then apple guidelines say, never exit programatically!!.
Any ideas ?

You misunderstand what is happening. If you enable UIApplicationExitsOnSuspend, this means your app will terminate when normally the app would go to the background. If you run your app then let the phone sit idle until the screen goes dark, your app is still in the foreground so it is not terminated. When a device goes into standby mode, the current app is still the current app. When you wake the device, you are not looking at snapshot of your app, you are looking at your running app. Double-tapping the Home button at this point doesn't show your app because your app is the currently running app.
Your app will be terminated if you return to the home screen or switch to another app. But it will not terminate just because the device went into standby mode.
If you want your app to return to its main screen when the device is woken up, then you need to put code in the UIApplicationDelegate applicationDidBecomeActive: method to reset your user interface.

Related

Debugging killed app in xcode debugger(Notification Debugging)

My notifications is crashing the IOS App when the user clicks the notification after the app was killed and removed from the background/foreground. I don't know how to get debugging information if the app isnt being ran.
You need to edit your scheme, choose Run on the left bar. and Info on the top tab bar.
Change Launch to wait for executable to be launched.
Now, you can run the app. the app will not launch and therefore, will not crash.
get the notification, open it, and debug the crash.

How to start Apple Watch app when user makes some action in iOS app

I was told multiple times that other apps do this but I can't seem to find any documentation on how to do that.
The behavior I would like to achieve is:
User starts iOS app and navigates to particular screen.
User presses start action/workout button and starts action/workout on iOS app.
At the same time user's Watch wakes up and shows corresponding screen in Watch app which acts as info screen for the current action/workout in iOS app.
User can press pause button on Watch and pause the action/workout in iOS app (this part is working already via WCSession).
So the question is basically how can I launch Watch app when either iOS app starts or when user does something in iOS app?
P.S. It is not a question of launching iOS app from Watch app, AFAIK for that I can use handoff.

Are terminated apps removed from the app switcher?

If an app is suspended and the system decides to terminate it, is it removed from the app switcher or does the app switcher retain a snap shot of the app as if its still suspended?
It will stay there until the user swipes up to kill it. When the user returns to the snapshot of a killed app it will simply relaunch.
Apps terminated by iOS are not (normally) removed from the app switcher. However, if the user swipes up on the app to remove it from the app switcher, that app is (normally) also terminated.
I say "normally" because Apple does not document this behavior and may be subject to future changes. But this is how the app switcher currently appears to behave.

Do iPhones get sent to home screen after long periods of inactivity?

Usually, if one locks an iPhone while on a certain app, then unlocks it, that same app will be on the screen.
I've heard that after long periods of inactivity, (in the locked screen state), when the phone unlocks it doesn't show the app that is currently open, rather sends it to the background and goes to the home screen.
Is this true?
The App may be terminated in the background, but will be reopened if the user unlocks his device. This does not happen to Apps that play audio.
You may want to check about background execution.

How to keep Chrome Cast running in background iOS?

I have a simple question when you go to home screen of iPhone and do not quit the application than the chrome Cast device stops playing the video on screen how can I keep playback alive while the application is running in background.
If you have a video app and it is running in a cast device, you would want the following behavior:
if user "explicitly" disconnects a device (through the cast menu), then receiver should look at the connected devices and see if there is any "other" connected device. If there is none, it should stop the application on the cast device. If, however, it finds another connected device, it should not stop the app.
If user doesn't explicitly disconnect but device gets disconnected since the app goes into background, or phone goes out of wifi range, or it battery dies, or ..., then receiver should not stop the app and should let it run, even if there is no other connected sender.
If you follow these two in the design of your app and your receiver, then you shouldn't have any issue when your phone goes to sleep or your app goes to background. Do you still see an issue given the above?

Resources