如何在iOS 10中发布没有声音的本地通知?

时间:2016-10-08 07:24:55

标签: ios objective-c localnotification unnotificationrequest

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

通知声音都是默认声音。

但如果我没有设置声音,则本地通知将无效。

有没有人有任何想法?非常感谢!

0 个答案:

没有答案