我正在创建一个警报应用程序,因为我创建了显示消息和播放声音的通知。但是现在它只在后台工作,我必须最小化我的应用程序来触发我的通知,如果我的应用程序是打开的,那么通知不会显示。
通知代码是:
- (void)viewDidLoad
{
[super viewDidLoad];
dateTimePiker.date = [NSDate date];
}
- (void)scheduleLocalNotificationWithDate:(NSDate *)fireDate
{
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.fireDate = fireDate;
notification.alertBody = @"Wake up";
notification.soundName = @"ma.mp3";
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
- (IBAction)SetAlarmBtnTapped:(id)sender {
.....
.....
[self scheduleLocalNotificationWithDate:dateTimePiker.date];
}