Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
147 views
in Technique[技术] by (71.8m points)

android - How to mute push notifications?

I am using Cordova FCM plugin in order to push notifications either for Android and 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)?

question from:https://stackoverflow.com/questions/66058907/how-to-mute-push-notifications

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

For iOS, When requesing for user Permmission we pass the array of required values

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

From the above, just remove .soundfrom options array.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...