I want to have a local notification show up as soon as the application is downloaded off the app store and is opened. Thanks.
Asked
Active
Viewed 65 times
0
-
Do you also want this notification on the first launch after application has been upgraded to a new version? – rakmoh Jun 27 '13 at 13:45
-
No, only for my current update. – Arman Puri Jun 27 '13 at 13:48
1 Answers
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