Jesus Lozano
Posts: 0
Joined: Thu Jun 19, 2014 3:35 pm

deviceID: how to set and send in POST requests to a Server?

Hello,

I am creating an App and all I want is to set the deviceID variable at the start of the Application and send it to a Server via a POST Request,- my understanding is that it is the "pushNotificationDeviceID" storage variable, but I am unable to do it.

I read that Push Notifications have to be Enabled under "Settings" in "Push Notifications". I have done that to no avail.

It seems that other documents state that my App has to perform a Push in order to register a device. If that is the case I can configure that, but really I do not need my App to perform a Push, all I want is to grab a deviceID, store it internally and send it to a Server via a POST. I have not been able to do that. Is this possible?
Or the only way is to perform a Push from the App? Or do I have to create an Application in Goggle Cloud? It seems like all that should not be necessary, but if there is no other way I will do it.

Thanks,

Jesus Lozano

Egor Kotov6832188
Posts: 0
Joined: Wed Nov 19, 2014 5:15 pm

deviceID: how to set and send in POST requests to a Server?

Hello Jesus.

1) Click "Create new"
2) Select Service
3) Pick Rest
4) Set options for your service like: method(POST), url, request- query string. Open test tab of service, click test, once you will get correct request for your service you can add to the page and use it

5) open your start page of app
6) go to data and add your service
7) open before send mapping
8) click js for parameter which should have device ID
9) Place next code:
return localStorage.getItem('pushNotificationDeviceID');

10)go back to design and add button, name it "Send"
11) on click event invoke your service.

Jesus Lozano
Posts: 0
Joined: Thu Jun 19, 2014 3:35 pm

deviceID: how to set and send in POST requests to a Server?

Hello Egor,

I think the point where I am stuck is where you write:
"8) click js for parameter which should have device ID"
I have created a storage variable named "pushNotificationDeviceID" , but it does not store any value. From what I read sometimes I think that it should acquire a value automatically, although other information seems to imply that I must perform a Push from the App to have that storage variable store something. If that is the case, OK, I will configure a Push, although I do not really need it, I just want for the App to store some value obtained from the device in a storage variable and send it in a POST request.

Please advice,

Jesus Lozano

Egor Kotov6832188
Posts: 0
Joined: Wed Nov 19, 2014 5:15 pm

deviceID: how to set and send in POST requests to a Server?

Hello Jesus,
You don't need to create pushNotificationDeviceID, it is already created, and wiil be defined with deviceId value right after device ready event

Jesus Lozano
Posts: 0
Joined: Thu Jun 19, 2014 3:35 pm

deviceID: how to set and send in POST requests to a Server?

Hello Egor,

I am following the steps you mention and what I get at the Server is a value of null. Seems like the Javascript code is not finding that 'pushNotificationDeviceID' Item. I think some kind of initiation routine is needed to have some value there.

Take care,

Jesus Lozano

Jesus Lozano
Posts: 0
Joined: Thu Jun 19, 2014 3:35 pm

deviceID: how to set and send in POST requests to a Server?

Egor,

I notice that the database associated to my app does not have any devices registered. I am thinking that might be the reason of deviceID not being populated. I have configured though, everything I think is necessary to have my app populate the database: Push Enabled in Settings, a Google Cloud App Sender ID and API captured....not sure why that database is not populated.

Please advice,

Jesus Lozano

Jesus Lozano
Posts: 0
Joined: Thu Jun 19, 2014 3:35 pm

deviceID: how to set and send in POST requests to a Server?

Hello Egor,

Would you please let me know if you have any news on this?

Take care,

Jesus Lozano

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

deviceID: how to set and send in POST requests to a Server?

Hi Jesus,

Please try following:

  1. Add start page "device ready" event handler.

  2. Populate it with following JS code:

    pre

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

    /pre

    Test this app on the device and take a look what actual deviceID you have in alert.

    Regards.

Return to “Issues”