ionic-team / ng-cordova

OBSOLETE: Please move to Ionic Native https://github.com/ionic-team/ionic-native
https://github.com/ionic-team/ionic-native
MIT License
3.48k stars 1.05k forks source link

Error: `PushNotification.init` is not a function #1268

Open greenlaw110 opened 8 years ago

greenlaw110 commented 8 years ago

I am using push_v5 plugin and phonegap push plugin. I found it doesn't work on my ios app built by ionic ios platform. The error message is:

TypeError: PushNotification.init is not a function. (In 'PushNotification.init(t)', 'PushNotification.init' is undefined)

The relevant source code of push_v5:

image

I did a bit research on this issue and found there are two different phonegap push notification plugin:

  1. https://github.com/phonegap/phonegap-plugin-push/
  2. https://github.com/phonegap-build/PushPlugin

It looks like push_v5 works with the first one, however we are using the second one which does not provide the init function instead this is what it did to initialize a PushNotification plugin:

image

And the safari debug tool verified that:

image

Question: does push_v5 works with the phonegap-build version at all (if we make it pick up the window.pushNotification instance). Or are you going to support that?

greenlaw110 commented 8 years ago

Okay, I am pretty sure push_v5 doesn't work with the https://github.com/phonegap-build/PushPlugin. I got the new error after adding an init method to PushNotification module:

TypeError: r.on is not a function. (In 'r.on("registration",function(e){t.resolve(e.registrationId)})', 'r.on' is undefined)
gortok commented 8 years ago

You are correct; it works for the first plugin, not the second. If you want to create a patch that lets it work for both, I'll gladly accept a PR.

frey1esm commented 7 years ago

How was this solved? I am getting uncaught TypeError: PushNotification.init is not a function while using the first plugin https://github.com/phonegap/phonegap-plugin-push/