0

アプリケーションがアプリストアからダウンロードされて開かれるとすぐに、ローカル通知を表示したいと考えています。ありがとう。

4

1 に答える 1

0

アプリデリゲートの didFinishLaunchingWithOptions でそれを行うことができます。このメソッドでは、次のことを行う必要があります。

- (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"]; 
    }
    .....
}
于 2013-06-27T14:34:54.190 に答える