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:@""]
通知音はどちらもデフォルトの音です。
サウンドを設定しないと、ローカル通知が機能しません。
誰かアイデアはありますか?どうもありがとう!