我想要合併在一定時間間隔後觸發的localnotifications,但是,我似乎無法在使用模擬器進行測試時在任何時候顯示通知。模擬器不顯示UILocalNotification
我只是想在創建10秒後顯示本地通知,但是,在模擬器中運行應用程序時,無論應用程序位於前臺還是後臺,都不會顯示任何內容。
我錯過了什麼嗎?這可能對時區有用嗎?
//通知設置
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];
localNotification.alertBody = @"Testing";
localNotification.alertAction = @"Show me the item";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] + 1;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
//這是在我的應用程序委託
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Reminder" message:notification.alertBody delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
如果您註釋掉時區,會發生什麼情況? – rocky