Nick Holmes
Nick Holmes

Reputation: 13

Resume to last view controller from background

I've got an iOS application that requires the user to log in before using its features. It uses Bluetooth and location services in the background after logging in. The typical use of the application is:

The way the app handles logins is via a session token which times out after 12 hours.

If I leave the application running overnight, however, upon resuming the application it starts up the log in view controller (a.k.a. the root view controller). I need the application to resume on the page it was closed on and can't seem to find any reference online as to how to do this.

I did find something about saving and resuming state but could get a definitive answer. Any help?

Upvotes: 1

Views: 347

Answers (2)

Wayne Hartman
Wayne Hartman

Reputation: 18487

UIStateRestoration is the mechanism that Apple provides for your application to be archived when it is backgrounded. Even if the app is eventually terminated by the operating system, UIStateRestoration provides APIs to restore the state of your application to where the user left.

Resources:

State Preservation Programming Guide

Upvotes: 1

Luca D'Alberti
Luca D'Alberti

Reputation: 4859

If you didn't define a background task, the app will be killed once it stays over 20 minutes in background

https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html

Upvotes: 0

Related Questions