Page 1 of 2

Push notification to specific device

Posted: Thu May 30, 2013 9:51 am
by andi

I try to get push notification running,but i don't know how to get the device id which i should enter into the DeviceID Field on the page https://appery.io/backend/push#send_tab
I tried the value from device.uuid but nothing happens
if i leave the value blank the notifications works


Push notification to specific device

Posted: Thu May 30, 2013 12:04 pm
by Kateryna Grynko

Hi Andreas,

DeviceID is a device serial number. You can get it calling JS function:
codePushNotification.getDeviceUniqueIdentifier();/code
This tutorial may be helpful: http://docs.appery.io/tutorials/sendi...


Push notification to specific device

Posted: Thu May 30, 2013 2:27 pm
by Emmz

Does
code
PushNotification.getDeviceUniqueIdentifier();
/code
Give same result as
code
localStorage.getItem('pushNotificationDeviceID');
/code

My assumption is Appery runs the first one (built-in) to generate the local storage value ?


Push notification to specific device

Posted: Thu May 30, 2013 4:04 pm
by Emmz

bump


Push notification to specific device

Posted: Thu May 30, 2013 4:05 pm
by Maryna Brodina

one minute:)


Push notification to specific device

Posted: Thu May 30, 2013 4:12 pm
by Maryna Brodina

PushNotification.getDeviceUniqueIdentifier() - is a function where you need to send callback function as an argument.
In localStorage variable pushNotificationDeviceID stores an identifier. It's recorded there while app start by using the PushNotification.getDeviceUniqueIdentifier() function (result of PushNotification.getDeviceUniqueIdentifier() is recorded to localStorage of pushNotificationDeviceID variable while app start). If you need identifier you should get it through localStorage.getItem('pushNotificationDeviceID');


Push notification to specific device

Posted: Thu May 30, 2013 4:17 pm
by Emmz

Ah... So like
code
pushNotification.getDeviceUniqueIdentifier(function(id){
alert(id);
});
/code
No point duplicating so I will just use the localStorage.getItem('pushNotificationDeviceID'); for device id
and
localStorage.getItem('pushNotificationToken'); for token

Thanks!


Push notification to specific device

Posted: Thu May 30, 2013 4:20 pm
by Maryna Brodina

Yes, you're right.


Push notification to specific device

Posted: Thu May 30, 2013 9:00 pm
by andi

Yes it works ...

One thing i have tried some time till i found it, it only works on APP's on devices not with the appery Test App


Push notification to specific device

Posted: Wed Jun 25, 2014 10:37 am
by Aeneas McBurney

I have created a localStorage variable called 'pushNotificationDeviceID' for my app. Does this get automatically populated with the device ID when opened on a mobile device or do I need to create a service to do so? I am writing this variable back to a database but its not populating when I open app on my android device which is why I am asking.

Thanks,
Aeneas