Page 1 of 1

getting access to deviceid

Posted: Fri Feb 28, 2014 9:05 pm
by mehtashail

Is there a way I can get direct access to the device id via a JS variable? I would like to send it back via the REST Service.

PhoneGap seems to have this as device.uuid. Is it possible to access this?


getting access to deviceid

Posted: Fri Feb 28, 2014 9:09 pm
by maxkatz

Yes, every app you create in Appery.io includes PhoneGap: http://docs.appery.io/getting-started

http://docs.phonegap.com/en/3.3.0/cor...


getting access to deviceid

Posted: Mon Mar 03, 2014 2:48 pm
by Joseph Joy Manadan

Whether the device id and the token is automatically created by appery when 'device ready' event fires OR we need to do it manually? I read somewhere that it is automatically stored in local storage(both device is and token) by appery. Can you clarify?


getting access to deviceid

Posted: Mon Mar 03, 2014 3:10 pm
by Nikita

Hello!

If you enable push notification for your app, deviceId will save automatically to appery's DB.


getting access to deviceid

Posted: Mon Mar 03, 2014 3:32 pm
by Joseph Joy Manadan

How can I retrieve those details. Where is the documentation for that?


getting access to deviceid

Posted: Mon Mar 03, 2014 9:42 pm
by Maryna Brodina

Hello!
device id is set on device ready event and stored in localStorage variable "pushNotificationDeviceID".
You can retrieve it at any time after Device ready event.
prealert(localStorage.getItem('pushNotificationDeviceID'));/preif you need to retrieve device id on Device ready event use setTimeout function. For example run the following code on device ready event:
presetTimeout(function(){
alert(localStorage.getItem('pushNotificationDeviceID'))
}, 1);/pre


getting access to deviceid

Posted: Mon Mar 03, 2014 10:54 pm
by Joseph Joy Manadan

Two things...

  1. Where can I find the orginal documentation for all those you just mentioned?
  2. What about token? How to retrieve it?

getting access to deviceid

Posted: Tue Mar 04, 2014 11:39 am
by Nikita

Hello!

Please look at this documentation: http://docs.appery.io/documentation/b...


getting access to deviceid

Posted: Tue Mar 18, 2014 9:56 pm
by Fred McIntyre

Nikita,
That documentation does not tell how to get the deviceID. In fact, it says that in order to get the deviceID you need to have the deviceID . Here is what it says:

pre
The get device service can be used for retrieving information about the device stored in the devices collection. The response of this service is JSON, which contains all predefined and user-defined fields of the devices collection. This service can be handy when you need to get the deviceID, check its timeZone, or any other operation involving device info.

To get device info from the database, send GET request with device id in the end of the associated URL:
https:&#47;&#47;api&#46;appery&#46;io/rest/push/reg/<deviceId>/pre

So, it says to get the deviceID I send a request which includes the deviceID. That documention is not very helpful.

However, Maryna's reply, above, is excellent.
prelocalStorage&#46;getItem(pushNotificationDeviceID)/pre

fyi, PhoneGap API device.uuid only gives the ID after the semicolon.