Search code examples
iosswiftsettingsapplication-settingsunnotificationrequest

Get User's Notification settings


Overview

  • I want to let users turn off notification sounds.
  • Usually in order to do so, one has to open the app settings(from Settings app as shown in the picture) and turn off notification sounds there.

Aim

  • I would like to display the value of Sounds in the app settings screen so that if it is on, the user can go to app settings and turn it off or vice-versa.

I tried to Google my problem and came across this but the links provided in the solution have been removed.

enter image description here


Solution

  • If you are specifically trying to read notification settings and options, you can do it with this. Then you can take them directly to the settings app yourself if they want to change it.

        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")
            }
        }