在我的應用程序中,我有觸發本地通知的對象。iOS >>本地通知>>添加到應用程序的徽章號碼雖然應用程序在後臺
當應用程序在後臺時,本地通知會在被解僱的時候觸發,並且工作正常。
由於某些原因,徽章號碼未更新。
當設置通知的對象,我使用下面的代碼:
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = obj.noteMeDate; //obj is an object for which the notification is created...
localNotification.alertBody = [NSString stringWithFormat:@"Note: %@", obj.title];
localNotification.alertAction = @"Show Me";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.soundName = UILocalNotificationDefaultSoundName;
localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1; //this is NOT WORKING...
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
有人嗎?
有沒有辦法在應用程序在後臺時對任何事件做出反應?我的意思是,它似乎仍然在某個地方「活躍」。沒有辦法指示應用程序對通知作出反應嗎? –
嘗試使用後臺任務API。 –