installing plugin #244

Closed
tahaemin opened this Issue Oct 20, 2015 · 8 comments

Projects

None yet

4 participants

@tahaemin

Hi, im workin on phonegap v5.3.6 and cordova v5.3.3. I did everything on README but plugin is not working.

Here is my code below;

onDeviceReady: function() {
        var push = PushNotification.init({
            "android": {
                "senderID": "MY_SENDER_ID"
            },
            "ios": {},
            "windows": {}
        });
        push.on('registration', function(data) {
            console.log("registration event");
            document.getElementById("regId").innerHTML = data.registrationId;
            console.log(JSON.stringify(data));
        });

        push.on('notification', function(data) {
            console.log("notification event");
            console.log(JSON.stringify(data));
            var cards = document.getElementById("cards");
            var push = '<div class="row">' +
                  '<div class="col s12 m6">' +
                  '  <div class="card darken-1">' +
                  '    <div class="card-content black-text">' +
                  '      <span class="card-title black-text">' + data.title + '</span>' +
                  '      <p>' + data.message + '</p>' +
                  '    </div>' +
                  '  </div>' +
                  ' </div>' +
                  '</div>';
            cards.innerHTML += push;
        });

        push.on('error', function(e) {
            console.log("push error");
        });
    }

It's not throwing any success or error message. What is wrong on this code phrase?

Thank you for your help

@mohitmayank

@tahaemin you code looks fine to me. are you sure your GCM setup is correct? whats the response from gcm server when you send the curl/http request for push.

@bmwsedee

Not sure if it is related, but when I tried to get the code working in an emulator it took me some time to figure out I had to set the target of my virtual device to 'Google API's (Google Inc.) - API Level 22' instead of just 'Android 5.1.1 - API Level 22'.
Subtle hint were the errors in logcat by the way, console didn't post any errors

@macdonst
Member

@tahaemin what @bmwsedee mentioned is your problem. If you are just using an "Android" emulator then it doesn't include Play Services but if you create a new emulator that uses the "Google" API's then you'll successfully build. Although my recommendation is to always use a device when testing push.

Please close this issue if the above comments resolve your problem.

@tahaemin

Hi again, thank you for your answers @mohitmayank, @macdonst & @bmwsedee . I'm using phonegap app for testing my apps. I'll try your suggestions then i'll give you information.

Thanks again.

@macdonst
Member

@tahaemin the PhoneGap Developer App does not include the native code required for the push plugin to function. I'm hoping to be able to add push test to this app by the end of the year but no promises. You'll have to build you own app to test push.

@macdonst macdonst closed this Oct 21, 2015
@tahaemin

@macdonst i built app via https://build.phonegap.com and i installed the app to my android device which is running on android 5.0.0, and it throws "[ERROR] Error initializing Cordova: Class not found.". i made double check for any error on my config.xml but there is no error in it. This is the last situation on my entegration. Waiting for your help.

@macdonst
Member

@tahaemin did you resolve your problem?

@tahaemin

No i did not. I think our problem is occured because of cordova-plugin-device. When i install and use it, it throws "Cordova class not found". My main objective is fixing this part, after that i will try push plugin. Thank you @macdonst

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment