0

I want to have a local notification show up as soon as the application is downloaded off the app store and is opened. Thanks.

Arman Puri
  • 45
  • 1
  • 8

1 Answers1

0

You can do that in your app delegate's didFinishLaunchingWithOptions. You need to do the following in this method:

- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
    ....
    //Get the version number of the application using this technique: http://stackoverflow.com/questions/458632/how-can-my-iphone-app-detect-its-own-version-number
    NSString version = [self appVersion];
    //Because you only want to display the notification on first launch so have a flag in user defaults to track that. Also note that you need to include this in your registerDefaults and set to NO
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
    BOOL alreadyDisplayedNotification = [defaults boolForKey:@"alreadyDisplayedNotificationOnStartForVersion"];
    if ([version isEqualToString:@"VersionForWhichYouWantNotification"] && !alreadyDisplayedNotification) {
        //Display Notification...

        // Set the flag in user default to track that notification has been displayed
        [defaults setBool:YES forKey:@"alreadyDisplayedNotificationOnStartForVersion"]; 
    }
    .....
}
rakmoh
  • 2,953
  • 1
  • 16
  • 14