ios - 获取用户的通知设置

标签 ios swift settings application-settings unnotificationrequest

概览

  • 我想让用户关闭通知声音。
  • 通常要这样做,必须打开应用程序设置(从设置应用程序,如图所示)并关闭那里的通知声音。

目标

  • 我想在应用设置屏幕中显示声音的值,这样如果它打开,用户可以转到应用设置并将其关闭,反之亦然。

我尝试用 Google 搜索我的问题并找到了 this但解决方案中提供的链接已被删除。

enter image description here

最佳答案

如果您专门尝试阅读通知设置和选项,则可以这样做。如果他们想要更改设置,您可以自己直接将他们带到设置应用程序。

    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/

相关文章:

ios - iOS应用中的多个Settings.bundle

c# - 无法在程序中命中断点。main Blazor 客户端 wasm

ios - iOS 客户端中的 XMPP 框架 XEP-0136 实现

ios - 如何在 Kony IDE 中导入原生 iOS 框架

ios - 不将文本字段识别为空

ios - 基于应用程序语言而不是设备语言的本地化请求权限

iphone -- 在游戏中心沙箱和生产环境之间切换

javascript - react native ,断断续续的独立并行动画?

ios - Swift UIScrollView 不滚动但响应 setContentOffset 和 Delegate 响应

android - 每个小部件实例的不同设置