简体   繁体   English

如何静音推送通知?

[英]How to mute push notifications?

I am using Cordova FCM plugin in order to push notifications either for Android and iOS.我正在使用 Cordova FCM 插件来推送 Android 和 iOS 的通知。 I want to allow the customer to mute the notifications - just mute, not block them.我想让客户静音通知 - 只是静音,而不是阻止它们。

But I can't find out how.但我不知道怎么做。 I know I can send from first place, from the server, without sound - but in such a case - everyone won't receive sound and this is not the aim.我知道我可以首先从服务器发送没有声音 - 但在这种情况下 - 每个人都不会收到声音,这不是目的。 I usually send for topics and from the server I cannot determine who configured his client to mute notifications.我通常发送主题和从服务器我无法确定谁将他的客户端配置为静音通知。

Is this possible to set mute from the client's app?这可以从客户端的应用程序中设置静音吗? How does WhatsApp handle this (there you can mute notification but not block them totally)? WhatsApp 如何处理这个问题(您可以将通知静音但不能完全阻止它们)?

For iOS, When requesing for user Permmission we pass the array of required values对于 iOS,当请求用户权限时,我们传递所需值的数组

UNUserNotificationCenter.current() 
.requestAuthorization(options: [.alert, .sound, .badge]) { granted, _ in
  print("Permission granted: \(granted)")
}

From the above, just remove .sound from options array.从上面,只需从选项数组中删除.sound

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM