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.When я поставил звукКак опубликовать локальное уведомление без звука в iOS 10?
[UNNotificationSound defaultSound]
или
[UNNotificationSound soundNamed:@""]
звук уведомления одновременно звука по умолчанию.
, но если я не настроил звук, местное уведомление не будет работать.
У кого-нибудь есть идеи? Большое спасибо!
Вы удалили UIRemoteNotificationTypeSound из registerForRemoteNotificationTypes? –
Нет, это не нужно. Я просто удаляю '' '' 'UNNotificationPresentationOptionSound'''' в завершенииHandler, как этот' '' 'completeHandler (UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionAlert)' '' ', и решить эту проблему –