概览
- 我想让用户关闭通知声音。
- 通常要这样做,必须打开应用程序设置(从设置应用程序,如图所示)并关闭那里的通知声音。
目标
- 我想在应用设置屏幕中显示声音的值,这样如果它打开,用户可以转到应用设置并将其关闭,反之亦然。
我尝试用 Google 搜索我的问题并找到了 this但解决方案中提供的链接已被删除。
最佳答案
如果您专门尝试阅读通知设置和选项,则可以这样做。如果他们想要更改设置,您可以自己直接将他们带到设置应用程序。
UNUserNotificationCenter.current().getNotificationSettings(){ (settings) in
switch settings.soundSetting{
case .enabled:
print("setting enabled")
case .disabled:
print("setting has been disabled")
case .notSupported:
print("somethings wrong here")
}
}
关于ios - 获取用户的通知设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49427166/