Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

"Undefined" when trying to retrieve push notification Token for my Smartphone

Hi Jaque,

Did you mistaken when write "tokeID" ?

Please show us your implementation screen shots.

Regards.

jaque
Posts: 0
Joined: Tue Oct 07, 2014 1:48 am

"Undefined" when trying to retrieve push notification Token for my Smartphone

Hi Yurii.

In order to accomplish the push notification tutorial from: http://devcenter.appery.io/documentat...

I set up the event at "device ready" it looks like this (for the push notification token):
Image

Thank for the support. Have a nice day!

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

"Undefined" when trying to retrieve push notification Token for my Smartphone

He Jaque,

Check whether you have correct values in fields "Sender ID" and "API Key". http://prntscr.com/4udvj9/direct

Also please use following code instead:

pre

setTimeout(function() {
alert(localStorage.getItem('pushNotificationToken'));
}, 1000);

/pre

Regards.

Jon Haider
Posts: 0
Joined: Thu Oct 16, 2014 2:53 pm

"Undefined" when trying to retrieve push notification Token for my Smartphone

I'm having the exact same trouble. Followed the Sending push notifications to a device tutorial. Then it directs you to the Push Notifications tutorial. Here, you are told to create events upon device ready to obtain the pushNotificationDeviceID and the pushNotificationToken. I created the event, on Device Ready, to run this script:
pre
setTimeout(function() {
alert(localStorage.getItem('pushNotificationDeviceID'));
}, 1);

setTimeout(function() {
alert(localStorage.getItem('pushNotificationToken'));
}, 1);
/pre
as seen here:
Image

I exported to .ipa, installed on my iphone 5s, and upon launching the app I get the deviceID. The database "Devices" collection is updated with my device and I can see the deviceID match what's on my iPhone screen.
Then the alert for the token comes up, and the value is "undefined" which is also how it appears in the "Devices" collection. So of course, when I try to send a push notification, and I go to Scheduled Push Notifications, I can see the error that the token only has 9 characters ("undefined") instead of the needed 64 or something.

How were others able to resolve this? Or did they stop responding because they gave up? lol

Thanks!!

Jon Haider
Posts: 0
Joined: Thu Oct 16, 2014 2:53 pm

"Undefined" when trying to retrieve push notification Token for my Smartphone

It looks like this issue came up here and here, without there being a clear resolution. I've followed all of the recommendations made in those threads as well, but nothing helped.
:)
I've noticed that others are defining the database URL and database ID differently than what I'm finding. Previous posts show this:

Image

but I don't know where these fields are defined...

In my Services/RESTService/Settings, I have defined it as this:
Image

Is there anything incorrect with this approach?
Thanks!

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

"Undefined" when trying to retrieve push notification Token for my Smartphone

Hi Jon,

Please use suggested code:

pre

setTimeout(function() {
alert(localStorage.getItem('pushNotificationDeviceID'));
alert(localStorage.getItem('pushNotificationToken'));
}, 1000);

/pre

Also please share your app with a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a. We will take a look.

Regards.

Anim
Posts: 0
Joined: Fri Jul 03, 2015 10:45 am

"Undefined" when trying to retrieve push notification Token for my Smartphone

I am facing the same problem and also row in my device collection is automatically deleted if I try to send notification and refresh device collection.

I followed the tutorial and it worked fine for my test app when when I trying to implement this I am facing this error

Return to “Issues”