What If User Declines Push Notifications

10 posts, 0 answers
  1. Jordan
    Jordan avatar
    16 posts
    Member since:
    Mar 2013

    Posted 21 Aug 2013 Link to this post

    I have several questions on push notifications that I haven't been able to find answers to while reading the available documentation.

    1) iOS prompts users to allow/decline push notifications for the app. From what I understand, this is an iOS feature independent of the app. If a user declines push from iOS, is that information available for me to know in the code? It would be pretty annoying for a user to decline push through the iOS prompt, and then get prompted by my app to register for push notifications. If the user does decline the iOS prompt but somehow registers for push in the app, will iOS catch and throw away any messages sent to the device?

    2) If an iOS user allows push from the iOS prompt and accepts push from my app but later changes their settings to deny push for my app, how should I handle that? Ideally, when the app loads up I would look and see if push is allowed for my app and check what the status in Everlive is and unregister the device if the device is registered but the app no longer has access to push. This kinda goes back to question 1 and being able to know whether a user has allowed push from iOS settings for the app.

    3) If a user declines registering for push in my app, how should that information be saved? Is that something that should be stored in internal storage so that I know they declined registering and don't prompt them again the next time the app loads? Is the device information sent to everlive with a "declined registration" marked?

    4) Should all devices get registered with Everlive regardless if they allow/deny push? Is whether the user accepts or declines push stored separately than the actual registration in Everlive? If so, Everlive would have access to information on every single device that uses my app and that seems dangerous to me.

    5) Can I test pushing messages to iOS devices in a test environment? I'm guessing all the registration will work but the actual APN functionality won't work until it gets in the app store, correct? I'm referring to running through Icenium Ion specifically. This seemed to be the case with the information I found on using custom push plugins and Icenium Ion.

    Looking forward to your response.

    Jordan
  2. Lyubomir Dokov
    Admin
    Lyubomir Dokov avatar
    43 posts

    Posted 27 Aug 2013 Link to this post

    Hello Jordan,

    Here are the answers to your questions:

    1. There are some APIs in iOS which can be used to find out what types of notifications are enabled for the current app. Here is a blog post that explains how to do this with Cordova(search for 'getRemoteNotificationStatus'): http://devgirl.org/2012/10/19/tutorial-apple-push-notifications-with-phonegap-part-1/

    2. You do not need to do anything specific in this case. When the user disables the push notifications, it will invalidate the push token (this token is what Everlive uses to send push notifications to the device). The next time you send a notification for this device, Everlive will try to send it to Apple and they will respond that this is an invalid token. Of course, if you have some specific logic that depends on that, you could resolve to step 1 and check the status.

    3. Usually, the app requests push notification permissions when the user opts for such from within the app. You should then invoke the enableNotifications() method from the Everlive SDK. It will give an error if the user rejects so that you will know. You can then store this in your app (internal storage). if necessary.

    4. No, you should only register in Everlive devices that allow push notifications. The process is in two steps - you get permissions for push first (invoke the enableNotifications() method). If it succeeds, only then you should register the device in Everlive (invoke the register() method). If you want to store the choice of the user, do it in the local storage.

    5. You can test push notifications with APN without having an app in the store. However, it must be on a real device, emulator will not do. Also, Ion will not work, because it does not have the push notifications plugin that is used for sending push notifications. You will have to deploy your app directly to the device. It is worth noting that Apple provides two environments for push notifications - development and production. You can read more about them here.



    Regards,
    Lyubomir Dokov
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  3. Jordan
    Jordan avatar
    16 posts
    Member since:
    Mar 2013

    Posted 29 Aug 2013 Link to this post

    Lyubomir,

    Thanks for your answers. After playing around a bit, I managed to get my Android device and iOS device to register in Everlive and receive push notifications. The portal is a nice resource and the SDK is super helpful as well.

    However, I still can't get the unregistering process to work in my app. I can remove the registered devices from the Everlive portal but cannot remove the devices when calling the code in the app. I've tried:

    a)
    el.push.currentDevice(emulatorMode).
    disableNotifications(successCallback, errorCallback) 

    b) 
    $.ajax({
      type: "DELETE",
      url: 'https://api.everlive.com/v1/ETxxxxxxxxxxxxx/Push/Devices/HardwareId/device_id',
      success: function(data) {
        alert("success: " + JSON.stringify(data));
      },
      error: function(data) {
        alert("error: " + JSON.stringify(data));
      }
    });

    c)
    el.push.currentDevice(emulatorMode).unregister(successCallback, errorCallback)

    I found (a) from the Introducing Push Notification blog article by Hristo which listed https://github.com/telerik/everlive-push-hybrid/blob/master/everlive-push-hybrid/scripts/app/main.js as a download example. Both (b) and (c) were listed in your Everlive documentation.

    All 3 ways work when the emulatorMode is set to true and I'm running in the simulator. The simulator device shows up as a registered device in Everlive and I can successfully unregister the device and remove it from Everlive through these calls (and through the Everlive portal). None of these ways work when I set the emulatorMode to false and build and run on the physical device. (a) does not get to the successCallback when I run on my device. Both (b) and (c) get to the successCallback function but the json data is {"Result": 0} and the device remains as a registered device in Everlive. I'm using the latest plugin for Cordova 2.7, found here: https://github.com/phonegap-build/PushPlugin. Enabling and registering work fine on the device. 

    I'm not sure if this is a bug on your side or if I need to do something different on my side or if security settings might be preventing the devices from getting unregistered. Please let me know what you find out.

    Thanks,
    Jordan
  4. Ivan Pelovski
    Admin
    Ivan Pelovski avatar
    16 posts

    Posted 30 Aug 2013 Link to this post

    Hello Jordan,

    You should use disableNotifications() function. It removes the device registration from Everlive and tries to unregister the device from GCM using the PushPlugin. I tried to replicate your scenario and indeed the PushPlugin v1.3.3 unregister function did not work on Android, and I even could not get the plugin work under iOS. I found this issue where people complain about the same thing https://github.com/phonegap-build/PushPlugin/issues/19. I have got the scenario working on Android with Cordova v2.4 and PushPlugin v1.1.1.

    If you don't want to downgrade then you may try use this code instead (this is what disableNotifications() actually does):
    Everlive.$.push.currentDevice()
        .unregister() // unregisters from Everlive
        .then(
            function () {
                var pushNotification = window.plugins.pushNotification;
                pushNotification.unregister(); // unregisters from GCM through PushPlugin. may fail
                // do smth else
            },
            function(err) {
                alert('UNREGISTER ERROR: ' + JSON.stringify(err));
            }
        );


    Regards,
    Ivan Pelovski
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  5. Darren
    Darren avatar
    32 posts
    Member since:
    Sep 2013

    Posted 06 Sep 2013 Link to this post

    Hi

    Having very similar problems. Using sample from Hristo. I am building for Android and running on the device. Code does not return from EnableNotifications() to either success or error. Have followed the sample readme to letter and very sure my projectid and APIKey are fine.
    Have wacked a number of alerts through the code and shows that EnableNotifications not returning - even an Error would be nice.
    I'm assuming permissions somewhere but can't find anything.

    Ideas

    Thanks
    Darren
  6. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 09 Sep 2013 Link to this post

    Hi Darren,

    Check out the detailed setup instructions for this sample in our documentation:Everlive Push Notifications Sample. Also make sure you're running the sample on a real device with provisioned build, as the push plugin does not work in the Icenium simulator or Icenium Ion.

    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  7. Darren
    Darren avatar
    32 posts
    Member since:
    Sep 2013

    Posted 09 Sep 2013 Link to this post

    Hi Steve

    Thank you for the reply.
    I am running the Android Build process in Icenium then scanning the QRCode with my Samsung S2 - Android 4.2

    Should the push notifications work under this senario

    thanks
  8. Darren
    Darren avatar
    32 posts
    Member since:
    Sep 2013

    Posted 09 Sep 2013 Link to this post

    Also Steve I should have mentioned I am running the 30 day trial - would that make a difference

    cheers
    Darren
  9. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 11 Sep 2013 Link to this post

    Hi Darren,

    All Telerik products are fully functional even when using trial versions, Icenium included. Your workflow is correct, I would suggest following the steps from the sample documentation to make sure you're not missing anything small.

    Regards,
    Steve
    Telerik

    Looking for tips & tricks directly from the Icenium team? Check out our blog!
    Share feedback and vote for features on our Feedback Portal.
  10. Darren
    Darren avatar
    32 posts
    Member since:
    Sep 2013

    Posted 11 Sep 2013 Link to this post

    Thanks Steve

    I have checked steps again and even re did app but still no go. At a loss now. Don't even receive an error returned from enablenotifications api.
    Planning on using Parse for Push now anyway I think
    Cheers
Back to Top