3
    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:@""]

通知的声音都是默认声音。

但如果我不设置声音,本地通知将不起作用。

有人有什么想法吗?非常感谢!

4

0 回答 0