UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
content.sound = [UNNotificationSound defaultSound];
NSDateComponents *components = [[NSDateComponents alloc] init];
components.hour = 0;
UNCalendarNotificationTrigger *trigger = [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:components repeats:YES];
UNNotificationRequest *notificationRequest = [UNNotificationRequest requestWithIdentifier:kUserNotificationTag content:content trigger:trigger];
[[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:notificationRequest withCompletionHandler:nil];
这是我在iOS10中发布本地通知的代码。当我设置声音是
时[UNNotificationSound defaultSound]
或
[UNNotificationSound soundNamed:@""]
通知声音都是默认声音。
但如果我没有设置声音,则本地通知将无效。
有没有人有任何想法?非常感谢!