Search code examples
cordovapush-notificationpushwoosh

PushWoosh Register Callbacks Before User Chooses


I'm trying to implement push notifications using the PushWoosh phone gap plugin. All of the examples, have the registerDevice event occur on deviceReady. However, I want the users to not get notified right away; so, I delay the registrations.

My problem is that the callbacks for registerDevice occur BEFORE the user actually chooses to allow the notifications or not. So, I'm getting a status that shows push is disabled when the user never actually made a choice yet.

How can I prevent my callback from firing until AFTER the user chooses to allow or not allow push notifications.

pushNotification.registerDevice(
  function(status) {
  // THIS CALLBACK IS CALLED INSTANTLY
  console.log("Register device status callback!");
  console.log(status);

  },
  function(status) {
  console.log("Register device fail callback!");
  console.log(status);

  }
);

Solution

  • Unfortunately that is iOS behavior. It sends the callback even before user presses agree or not. However you can get the status of notifications (enabled/disabled).

    Call getRemoteNotificationStatus function in the plugin. If you don't have "pushAlert" consider push notifications disabled (user will never see the alert).

    That exactly what Skype does for example.