Can I turn off/on push notifications through the app?

@warrenwsav

As far as I know, there’s no way to intercept if the user has accepted/denied access in the dialog as it’s handled internally by the OS.

@warrenwsav

With the GameThrive plugin you can also add a tag to a user in your Corona app like ‘GameThrive.TagPlayer( “notifications”, “off” )’  Then create a segment for users with that tag and always exclude that segment when sending notifications.

Here’s some example screenshots:

Screenshot%202014-05-21%2022.22.43.png

Screenshot%202014-05-21%2022.23.17.png

@george18

The problem is still that it’s not possible to know if the user has chosen to accept/reject push notifications…

@ingemar

The tag setting in my example would have to be based on an in-app on/off button.

But for iOS it does assume that the user accepted push notifications from the native dialog. And unfortunately until jonjonsson’s feature request is addressed, the moment that the native dialog shows up can not be controlled (it shows up right away when the app is first started).

You can generally tell if a user accepted/declined push notifications in the native dialog starting with iOS7 though. There’s a callback that happens and if the user declined push then the callback will not have a device token passed to it. The caveats are that it will not work if their network connection is not available, and it will return a token even if they declined push notifications on iOS6 and below.

@george18

What I meant is that there’s no way for Pro subscribers to do that within Corona SDK.
Enterprise would be the only exception.

You can do it in all versions of Corona actually. Subject to the caveats in my last message of course.

Here’s how you can do it:

function notificationListener( event ) if ( event.type == "remoteRegistration" ) then     print(“The player accepted push notifications and here is their token: " .. event.token) end end Runtime:addEventListener( "notification", notificationListener )

(Or, if you’re using GameThrive)

function IdsAvailable(playerID, pushToken) if (pushToken) then print(“The player accepted push notifications and here is their token: " .. pushToken) end end GameThrive.IdsAvailableCallback(IdsAvailable)

Sorry, my bad!

We all learn something new every day  ;) …