2016-10-08 16 views
0
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にローカル通知を掲示する私のコードです。

ただし、サウンドを設定しないと、ローカル通知は機能しません。

誰にでもアイデアがありますか?ありがとうございます!

+0

詳細は、あなたがregisterForRemoteNotificationTypesからUIRemoteNotificationTypeSoundを削除しましたか? –

+0

いいえ、それは必要ありません。私はこの '' '' completionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionAlert) '' 'のようなcompletionHandlerで' '' '' UNNotificationPresentationOptionSound'''''を取り除いて、この問題を解決してください。 –

答えて

0

いいえいいえサウンドを無効にすることはできません。なぜなら、UILocalNotificationではオプションが用意されていないからです。だから、あなたのアプリケーションバンドルに空のサウンドファイルを追加して使用することをお勧めします。あなたができるrefer here

+1

これは私の多くの時間を節約します〜 –

+0

私は、このコンプライアンスのようにcompletionHandler(UNNotificationPresentationOptionBadge | UNNotificationPresentationOptionAlert)を '' ' - (void)jpushNotificationCenter :(UNUserNotificationCenter *)センターwillPresentNotification:(UNNotification *)通知withCompletionHandler: (NSInteger))completionHandler''''そして何らかの方法でこの問題を解決する –

関連する問題