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];
は、これは私が音、通知の音はデフォルトのサウンドの両方でiOS 10で音声なしでローカル通知を送信するにはどうすればよいですか?
[UNNotificationSound defaultSound]
または
[UNNotificationSound soundNamed:@""]
で設定iOS10.Whenにローカル通知を掲示する私のコードです。
ただし、サウンドを設定しないと、ローカル通知は機能しません。
誰にでもアイデアがありますか?ありがとうございます!
詳細は、あなたがregisterForRemoteNotificationTypesからUIRemoteNotificationTypeSoundを削除しましたか? –
いいえ、それは必要ありません。私はこの '' '' completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionAlert) '' 'のようなcompletionHandlerで' '' '' UNNotificationPresentationOptionSound'''''を取り除いて、この問題を解決してください。 –