0
有人可以看看下面的代碼,並告訴我爲什麼本地通知不會觸發。我在XCode中運行應用程序,並使用調試選項來模擬後臺獲取,但本地通知不會觸發。本地通知不會觸發後臺抓取
- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
{
NSLog(@"performFetchWithCompletionHandler");
UILocalNotification *localNotif = [[UILocalNotification alloc] init];
if (localNotif) {
localNotif.alertBody = @"Update demo text!";
localNotif.alertAction = @"OK";
localNotif.soundName = UILocalNotificationDefaultSoundName;
localNotif.fireDate = nil;
NSLog(@"Local Notification");
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif];
}
//Perform some operation
completionHandler(UIBackgroundFetchResultNewData);
}
啊,我不認爲可能是它。 – ORStudios
完美,這是問題所在。謝謝 – ORStudios