Check user settings for push notification in Swift

前端 未结 6 803
滥情空心
滥情空心 2021-02-12 12:54

I have push notifications in my app. Whenever the app is launched, I would like to check whether the user has enabled push notification for my application.

I do it this

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-12 13:37

    Swift 4 version of salabaha's answer

    extension UIApplication {
        class func openAppSettings() {
            UIApplication.shared.open(URL(string: UIApplicationOpenSettingsURLString)!, options: [:], completionHandler: {enabled in
                // ... handle if enabled
            })
    }
    

提交回复
热议问题