user2070420
user2070420

Reputation: 533

Want to display an alert when the app enters foreground from background

I am trying to build an iOS app, where when the app enters background and the user brings it to foreground, I want to display a message like "Welcome Back", Is there a way of doing that? I have read about the UILocalNotification but that is not what I want.

Upvotes: 0

Views: 494

Answers (2)

PAcan
PAcan

Reputation: 869

Yes, of course. For such kind of methods you should always look in AppDelegate.m file. It has the default method:

- (void)applicationWillEnterForeground:(UIApplication *)application 
{
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Welcome back!" message:@"Welcome back!" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
    [alert show];
}

Some of that kind...

Upvotes: 2

rmaddy
rmaddy

Reputation: 318794

Implement the UIApplicationDelegate applicationWillEnterForeground: method. This is called when the app returns to the foreground.

Upvotes: 1

Related Questions