Swift ios checking if user has enabled notifications always return true -
this question has answer here:
i trying check if user has enabled remote notifications app return true if disable/uninstall app.
i checking code:
if uiapplication.shared.isregisteredforremotenotifications == false { onesignal.registerforpushnotifications() print("notifications off") } else { print("notifications on") } but run: print("notifications on")
so how can check if user has enabled notification app?
if let settings = uiapplication.shared.currentusernotificationsettings { if settings.types != uiusernotificationtype() { print("is on!") }else{ print("is off!") } }else{ print("is off") } this seems work, not sure if right way?
Comments
Post a Comment