任何人都可以请告诉我如何在我的应用程序处于后台时获取UILocalNotification
。后台本地通知
我在这里发布我的代码。提前致谢。
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif == nil)
return;
localNotif.fireDate =[startDate addTimeInterval:60];
NSLog(@"%@",localNotif.fireDate);
localNotif.timeZone = [NSTimeZone defaultTimeZone];
localNotif.alertAction = @"View";
localNotif.soundName = UILocalNotificationDefaultSoundName;
NSString *notifStr=[NSString stringWithFormat:@"Hey looks like you're meeting up with %@, why don't you let your other friends know what fun they're missing out on? Share a photo :)",[itemDict objectForKey:@"fname"]];
NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:notifStr ,@"notifKey",nil];
localNotif.userInfo = infoDict;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
[localNotif release];
你是什么意思“获取本地通知,而应用程序在后台”?如果您安排本地通知,并在应用程序处于后台时触发,用户将看到警报视图,但就是这样。你无法收到一条消息告诉你本地通知被触发! – Dabrut
在我的情况下,它并没有被解雇。我不知道为什么? –
startDate的价值是什么?尝试[NSDate dateWithTimeIntervalSinceNow:60]并删除时区 – Dabrut