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

installing plugin #244

Closed
t13n opened this issue Oct 20, 2015 · 9 comments
Closed

installing plugin #244

t13n opened this issue Oct 20, 2015 · 9 comments

Comments

@t13n
Copy link

t13n commented Oct 20, 2015

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
Copy link

@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
Copy link

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
Copy link
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.

@t13n
Copy link
Author

t13n commented Oct 21, 2015

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
Copy link
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.

@t13n
Copy link
Author

t13n commented Oct 21, 2015

@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
Copy link
Member

@tahaemin did you resolve your problem?

@t13n
Copy link
Author

t13n commented Oct 27, 2015

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

@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

4 participants