Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

PushNotification not defined #21

Closed
FernandoMedin opened this issue Jun 24, 2015 · 9 comments
Closed

PushNotification not defined #21

FernandoMedin opened this issue Jun 24, 2015 · 9 comments

Comments

@FernandoMedin
Copy link

Hi. Using almost the same code in example e got an error message saying that. I got this errro puting a Try before "var push".
The code:
"""
try{
var push = PushNotification.init({
"android": { "senderID": "xxxxx" }
});
}catch(err){
alert("Error: " + err.message);
}
"""
In config XML I've add the lines:
"""
feature name="PushNotification"
param name="android-package" value="com.adobe.phonegap.push.PushPlugin"/
/feature
"""
I'm doing something wrong? Thanks.

@macdonst
Copy link
Member

@FernandoMedin that's not the correct plugin ID. The plugin ID for this package is "phonegap-plugin-push". If you are running the PhoneGap 5.0 command line then doing a:

phonegap pluging add phonegap-plugin-push

it will setup your config.xml for you. Let me know if this doesn't resolve things for you.

@FernandoMedin
Copy link
Author

@macdonst thanks for the reply! But, I'm getting the same error. I just tested using phonegap-build. Should I use the command line to build the app?
At this time I just ran the command line in a new project and edit index.js to put the "Try".

Thanks.

@macdonst
Copy link
Member

@FernandoMedin I don't think the plugin has been uploaded to PhoneGap Build. If you are using PhoneGap/Cordova CLI 5+ then:

phonegap create pushtest
phonegap platform add android
phonegap plugin add phonegap-plugin-push
// edit the html/js
phonegap run android

Substitue ios for android if you want to test iOS.

@FernandoMedin
Copy link
Author

@macdonst, that works! The problem was with phonegap build so. Anyway, thank you very much! Any ideia if the plugin will be available in phonegap build?

@macdonst
Copy link
Member

@FernandoMedin I'm going to close this issue then as you have a work around. I'm off this week but putting in a few bug fixes as I have time. Hope to have the next version on PG Build be early next week. I'll create an issue for it.

@gongfan99
Copy link

Is this module in phonegap build yet? I have tried phonegap build and PushNotification is undefined.

@gongfan99
Copy link

@macdonst Thanks. It works nicely with phonegap build.

Just to benefit anyone who has the same issue and ends up here. What I did wrong was that I should manually bootstrap Angular in the "deviceready" callback, like this:

angular.module("myApp", [ ... ]);

angular.element(document).ready(function () {
    if (window.cordova) {
        document.addEventListener('deviceready', function () {
            angular.bootstrap(document, ['myApp']);
        }, false);
    } else {
        angular.bootstrap(document, ['myApp']);
    }
});

And the "ng-app" tag need to be removed from the index.html to prevent auto bootstrap.

@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants