0

我正在为指定日期创建本地通知,如下所示

UILocalNotification *localNotify = [[UILocalNotification alloc]init];
        [localNotify setFireDate:notificationDate];
        [localNotify setTimeZone:[NSTimeZone localTimeZone]];
        [localNotify setAlertBody:@"Daily Items Reminder"];
        //[localNotify setAlertLaunchImage:@"blank_Btn"];
        [localNotify setAlertAction:@"View"];
        [localNotify setSoundName:UILocalNotificationDefaultSoundName];
        [localNotify setApplicationIconBadgeNumber:1];
        [localNotify setRepeatInterval:NSDayCalendarUnit];
        NSDictionary *userDict = [NSDictionary dictionaryWithObject:@"dict"
                                                             forKey:@"key"];
        localNotify.userInfo = userDict;
        [[UIApplication sharedApplication] scheduleLocalNotification:localNotify];
        [localNotify release];

在我的ApplicationDidFinishLaunching中,我为UILocalNotification创建了一个对象,如下所示

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];

UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];

if (notification)
{
    NSInteger badgeNumber =  notification.applicationIconBadgeNumber;

    if (badgeNumber < 0)
    {
        notification.applicationIconBadgeNumber = 0;
    }
    else
    {
        notification.applicationIconBadgeNumber = badgeNumber - 1;
    }

    [self showAlertMessage:@"didFinishLaunchingWithOptions" withButtons:eOk forDelegate:self];
    // open screen
}
}

在出现本地通知时单击查看按钮后,应用程序启动,现在launchOption应该通过键返回本地通知对象,但它总是返回 nil,因为没有调用警报视图??..我可能做错了什么?

4

0 回答 0