Swift ios checking if user has enabled notifications always return true -


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

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -