Titanium - get the status of the push registration (ios)

Answered

Comments

18 comments

  • Avatar
    Vitaly Romanychev

    Hello Dan,

    At the moment such functionality is not available yet. Please note that its implementation is being discussed by our development team, so it is expected to be released, however I cannot provide any ETA at the moment.

  • Avatar
    Fabian Hust

    Thank you for your reply.

    I think this is something that shouldn't be too hard to do, I think there is already implemented in the native side of the SDK: https://github.com/Pushwoosh/pushwoosh-ios-sdk/blob/master/Documentation/PushNotificationsManager.md#getremotenotificationstatus

    What I'm trying to build (and what I need it for) is a "smart" way of asking people to accept the push notification and in the same time try to get on board those that denied this in a previous version of the app. But for this I need to know what's the status of the PN.

    Thank you.

  • Avatar
    Fabian Hust

    Hi, If anyone has trouble with this, I found out that Titanium's

    Titanium.Network.remoteNotificationsEnabled

    behaves correctly, so you can find out if the device has the permission to receive push notifications :)

  • Avatar
    Rob Willett

    Would like this as well in the Cordova SDK if at all possible please.

    Thanks

    Rob

  • Avatar
    Fabian Hust

    Can't you try to use the normal plugin for this? https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/API.md#pushnotificationhaspermissionsuccesshandler

    PS. This is a guess for me, I don't use cordova :)

  • Avatar
    Rob Willett

    Whoops thats embarrassing. Thought I knew the docs. Apologies

    Rob

  • Avatar
    Fabian Hust

    No reason to, let me know if it works, I'm curious :)

  • Avatar
    Rob Willett

    Just checked the docs and they are for a different plugin, does the PushWoosh plugin follow that one? Or are you loading two in?

    Rob

  • Avatar
    Rob Willett

    Have just checked the 'official' PushWoosh guide and can see getRemoteNotificationStatus there.

    Jumped the gun too quickly. I'm still an idiot for not reading the right guide.

    <doh>

    Rob

  • Avatar
    Fabian Hust

    well, I was about to push you to load 2 plugins, so we're even ;)

  • Avatar
    Rob Willett

    I had actually found this plugin

    https://www.npmjs.com/package/cordova.plugins.diagnostic

    but then discovered that it breaks Android builds.

    Can we use two push plugins together like this?

    Not planning it but interested to know.

    Rob

  • Avatar
    Rob Willett

    It also transpires that the function call returns the wrong value and always returns enabled = 1.

    We'll dig further into this, its rather frustrating.

    ==== Updated ====

    We've dug into this some more and it turns out we had misunderstood the docs for the function call.

    You need to test for pushAlert == 1 rather than enabled == 1.

    See https://rawgit.com/Pushwoosh/pushwoosh-phonegap-3.0-plugin/master/Documentation/files/PushNotification-js.html#PushNotification.getRemoteNotificationStatus

    for more information.

    Rob

  • Avatar
    Fabian Hust

    O honestly don't know if you can use 2 plugins in the same time that are supposed to access the same functionality (as I said I'm not using phonegap/cordova/ionic at all)

    As for the enabled=1 you might have to test for ios on device (I think the simulator returns true always). And android doesn't need this permission so it makes sense to be always true.

  • Avatar
    Rob Willett

    Hi,

    I was testing for IOS and I was running it on a real device. We'll dig into it some more.

    Rob

  • Avatar
    Fabian Hust

    One more note, if you accepted once, you need to fully delete the app on ios 9 and reinstall. On ios 8 is even worse (need to reboot the device few times, change the date, etc - search on google)

  • Avatar
    Rob Willett

    OK, we'll try that.

    Thanks

    Rob

  • Avatar
    Rob Willett

    I am aware we am hijacking this thread but this is our final post on the subject :) However I think it important to close this sub-discussion off with updated and correct information for anybody else who is reading this. Just to be clear, the incorrect information was from us and nobody else.

    We've dug into this some more and it turns out we had misunderstood the docs for the function call.

    You need to test for pushAlert == 1 rather than enabled == 1.

    See https://rawgit.com/Pushwoosh/pushwoosh-phonegap-3.0-plugin/master/Documentation/files/PushNotification-js.html#PushNotification.getRemoteNotificationStatus

    for more information.

    Also we have NOT had any issues with needing to uninstall, reinstall the app to get this setting to hold. Its worked for us fine. We can change the notification settings around in the Settings and it seems to work between app restarts.

    Thanks for all the help

    Rob

  • Avatar
    Vitaly Romanychev

    Great job here, guys!

    However this initially was a Titanium thread, so I would like to leave here a closing comment regarding this particular platform:

    As Dan Tamas offered, you can use Titanium.Network.remoteNotificationsEnabled to find out whether a device have accepted or rejected receiving Push Notifications.

Please sign in to leave a comment.