Hi All,

I followed the instruction on the site, and everything went well, until i kept on getting an error message "failed to register" which looks to me coming from pushNotification.registerDevice's callback (failed callback).

Any advice? I have been troubleshooting this for days now..

function initPushwoosh() { var pushNotification = cordova.require("com.pushwoosh.plugins.pushwoosh.PushNotification");

//set push notifications handler
document.addEventListener('push-notification', function(event) {
    //get the notification payload
    var notification = event.notification;

    //display alert to the user for example
    alert(JSON.stringify(notification));
});

//initialize the plugin
pushNotification.onDeviceReady({ appid: "137A9-86052", serviceName: "" });

//register for pushes 
pushNotification.registerDevice(
        function(status) {
            var pushToken = status;
            alert('push token: ' + pushToken);
        },
        function(status) {
            alert(JSON.stringify(['failed to register ', status]));
        }
);

}

asked 14 Aug '15, 15:41
Tupai86's gravatar image

Tupai86
1113

Hi,

Have you tried to reproduce this issue on the sample app? You can download it from the link below:

https://github.com/Pushwoosh/phonegap-3-sample-app

Additionally, this issue could be related to the unstable internet connection. Please check whether that could be the case.

permanent link
answered 18 Aug '15, 10:09
Andrew_H's gravatar image

Andrew_H
3766

Hi Andrew, thanks for your reply, i shall try this today and report back here!! :D

(19 Aug '15, 04:06) Tupai86 Tupai86's gravatar image

Hi Guys, FYI very sorry i got real busy with work, i will definitely test this and post my findings here!!

(24 Aug '15, 07:16) Tupai86 Tupai86's gravatar image

So! I have tested the "phonegap-3-sample-app" and the registration is working intermittently (1 success in 5 tries). Wonder what went wrong...

(24 Aug '15, 11:28) Tupai86 Tupai86's gravatar image

UPDATE!

After keep on playing around with the app, i realised, the app actually registered itself..

funnily, the registerDevice() function will fire the fail function, then trigger the success function.

So everytime i launch the app, it will say "failed to register", but then suddenly continue showing the device token, and suddenly the device is registered..

(24 Aug '15, 12:40) Tupai86 Tupai86's gravatar image

Hi,

This is quite strange. Am I correct that you are using the latest PGB plugin? Have you checked whether this issue is not related to the unstable internet connection?

(24 Aug '15, 12:43) Andrew_H Andrew_H's gravatar image

Hi Andrew :)

For version, i tried both: <gap:plugin name="pushwoosh-cordova-plugin" source="npm"/>

and

<gap:plugin name="com.pushwoosh.plugins.pushwoosh" version="3.4.2"/>

Both are behaving the same.

(24 Aug '15, 12:50) Tupai86 Tupai86's gravatar image

Just now i tried to tweak the registerDevice() like so:

//register for pushes 
pushNotification.registerDevice(
        function(status) {
            var pushToken = status;
            console.warn('token: ' + pushToken);
        },
        function(status) {
            console.warn(JSON.stringify(['failed to register ', status]));
        }
);

Guess what?? The fail function is no longer running.. On the console, i only get the "token: blah blah blah"

the only thing i change on the registerDevice() is to change from using alert() to console.warn()

(24 Aug '15, 12:50) Tupai86 Tupai86's gravatar image
showing 5 of 7 show 2 more comments
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×91
×76
×26
×12

question asked: 14 Aug '15, 15:41

question was seen: 869 times

last updated: 24 Aug '15, 12:50