Search code examples
iosswiftunusernotificationcenter

Switch to enable/disable local notifications (swift 4)


I am making a Todo app and there supposed to be a switch button in inside of an application settings to enable/disable all local notifications.

I tried removeAllPendingNotificationRequests() method, but it deletes all notifications altogether and i want to keep them scheduled but not doing anything. Is it even possible ?

Thanks a lot


Solution

  • you cannot change notification setting from the app but you can navigate your users to setting of your app so they can change notification settings

    if let aString = URL(string: UIApplicationOpenSettingsURLString) {
                UIApplication.shared.open(aString, options: [:], completionHandler: { success in
                    SlideNavigationController.sharedInstance().closeMenu {
    
                    }
                })
            }