Reputation: 1155
User refuses location, I send user to Location settings on Settings app:
UIApplication.sharedApplication().openURL(NSURL(string:"prefs:root=LOCATION_SERVICES")!)
User authorizes location from Settings app, returns to my app with Back to App
on top left
How do I know that he came back to the app? viewDidAppear
doesn't work
Upvotes: 4
Views: 2353
Reputation: 9246
You can easily detect by checking AppDelegate's
method:-
func applicationWillEnterForeground(application: UIApplication!) {
Or by registering a notification in your view controller's viewDidLoad() by NSNotificationCenter
:-
NSNotificationCenter.defaultCenter().addObserver(self, selector: "applicationWillEnterForeground", name: UIApplicationWillEnterForegroundNotification, object: nil)
//calling selector method
func applicationWillEnterForeground() {
println("did enter foreground")
}
Upvotes: 4
Reputation: 2598
Use NSNotificationCenter in your viewController
Call this on viewDidLoad
- (void)registerAppEnterForeground
{
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(applicationWillEnterForeground)
name:UIApplicationWillEnterForegroundNotification
object:nil];
}
-(void)applicationWillEnterForeground
{
/*HANDLE YOUR CODE HERE*/
}
Upvotes: 0