如果您没有定义alertBody,则不会调用UILocalNotification回调

时间:2016-12-12 09:27:09

标签: ios objective-c uilocalnotification

UILocalNotification *soundNotification = [[UILocalNotification alloc] init];
soundNotification.repeatInterval = NSCalendarUnitMinute;
soundNotification.soundName = @"alarm.mp3";
soundNotification.fireDate = [NSDate date];
soundNotification.timeZone = [NSTimeZone defaultTimeZone];
soundNotification.alertBody = @"alarm is ringing"; //commenting out this line stop callback.
[[UIApplication sharedApplication] scheduleLocalNotification:soundNotification];

问题是我不想为通知定义alertBody。但仍然打了回调

- (void)application:(UIApplication*)application didReceiveLocalNotification:(nonnull UILocalNotification *)notification

因为如果我没有点击回叫,即使你打电话也无法停止通知的声音

- (void)cancelLocalNotification:(UILocalNotification *)notification;

有没有办法在没有为通知定义alertBody的情况下停止UILocalNotification声音?

0 个答案:

没有答案