任何人都可以請告訴我如何在我的應用程序處於後臺時獲取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