UILocalNotification* localNotification = [[UILocalNotificationalloc] init];
localNotification.alertBody = @"Your alert message";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
我没有收到本地通知,有人可以说如何获得本地通知。
答案 0 :(得分:2)
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:60];
试试这个!!!!
答案 1 :(得分:1)
您需要指定何时触发通知。您刚刚创建了通知但未在需要触发时设置。
例如......
localNotif.fireDate = [itemDate dateByAddingTimeIntervalInterval :-( minutesBefore * 60)];
答案 2 :(得分:0)
如果应用程序是前台阶段,那么你不会看到那些通知。你应该对委托方法进行编码。
-(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification;
答案 3 :(得分:0)
UILocalNotification *notif = [[UILocalNotification alloc]init];
notif.alertBody = @"Your Session is Ready";
notif.alertAction = @"Take Now";
notif.soundName = @"DingBell.wav";
[notif setFireDate:[gregCalendar dateFromComponents:dateComponent]];
notif.repeatInterval = NSWeekCalendarUnit;
[notif setTimeZone:[NSTimeZone defaultTimeZone]];
NSMutableDictionary *userDict = [NSMutableDictionary dictionary];
[userDict setValue:self.stringModuleID forKey:@"kRemindMeNotificationDataKey"];
[userDict setValue:[NSString stringWithFormat:@"alarm%d",[[setreminingDay objectAtIndex:i] intValue]] forKey:@"alarm"];
notif.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];