开发者

Iphone simulator : Local Notification fires twice but never displays?

Is there a bug with the simulator and Local Notifications or am I doing something incorrectly.

// on button click fire off notification for 30 seconds from now
-(IBAction)scheduleNotification{
    UILocalNotification *localNotif = [[UILocalNotification alloc] init];

    NSDate *item = [NSDate dateWithTimeIntervalSinceNow:30]; 

    if (localNotif == nil)
        return;     
    localNotif.fireDate = item;
    localNotif.timeZone = [NSTimeZone defaultTimeZone];
    localNotif.alertBody =  NSLocalizedString(@"Test Notification", nil);
    localNotif.alertAction = NSLocalizedString(@"View Details", nil);
    localNotif.soundName = UILocalNotificationDefaultSoundName;
    localNotif.applicationIconBadgeNumber = 0;
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
    [localNotif release];
}   



- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
    // Handle the notif开发者_JS百科icaton when the app is running
    NSLog(@"Recieved Notification %@",notif);
}

didReceiveLocalNotification logs 2 notifications, but the simulator never actually displays a notification.

Recieved Notification <UIConcreteLocalNotification: 0x5943450>{fire date = 2010-08-25 09:36:25 -0400, time zone = America/New_York (EDT) offset -14400 (Daylight), repeat interval = 0, next fire date = 2010-08-25 09:36:25 -0400}

Recieved Notification <UIConcreteLocalNotification: 0x5c53e00>{fire date = 2010-08-25 09:36:25 -0400, time zone = America/New_York (EDT) offset -14400 (Daylight), repeat interval = 0, next fire date = (null)}


You won't see any alert if you receive local/push notification while your app is running. Unless you show your own alert in application: didReceiveLocalNotification:, certainly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜