在应用程序处于后台时显示通知
Showing notifications while app in background
我需要在应用程序处于后台时显示某些本地通知。如果没有 NSNotificationCenter 的帮助,我该怎么做?
Andrey Chernukha 在第一条评论中是正确的。
下面是实现简单本地通知的代码:
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.repeatInterval = 0;
NSDate *now = [NSDate date];
NSDate *dateToFire = [now dateByAddingTimeInterval:10];
localNotification.fireDate = dateToFire;
localNotification.alertBody = @"Test local notification";
localNotification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
我需要在应用程序处于后台时显示某些本地通知。如果没有 NSNotificationCenter 的帮助,我该怎么做?
Andrey Chernukha 在第一条评论中是正确的。 下面是实现简单本地通知的代码:
UILocalNotification *localNotification = [[UILocalNotification alloc] init];
localNotification.repeatInterval = 0;
NSDate *now = [NSDate date];
NSDate *dateToFire = [now dateByAddingTimeInterval:10];
localNotification.fireDate = dateToFire;
localNotification.alertBody = @"Test local notification";
localNotification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];