1

I am using Mobilefirst 8.0 push notification part in cordova application downloaded sample application which is given by IBM. Its working fine. When I click on register device button device id I can see in mobilefirst console.

1) How I can get that same device ID in client side application?

2) User ID field also I can see in mobilefirst console device register information. How Can I add particular User ID while registering device?

user3747168
  • 43
  • 1
  • 9

1 Answers1

1

1) How I can get that same device ID in client side application? You can call the following REST endpoint in order to retrieve from the server various data about the application, including the deviceId: http://www.ibm.com/support/knowledgecenter/en/SSHS8R_8.0.0/com.ibm.worklight.apiref.doc/rest_runtime/r_restapi_push_device_registrations_get.html

2) User ID field also I can see in mobilefirst console device register information. How Can I add particular User ID while registering device?

The sample uses the MobileFirst security framework, and that's where the userId is coming from. Please refer to the security documentation, tutorials and samples:

The same userId is also used by the Push service by default (Push retrieves the user id from the request being made and if the user is already logged in, the userid part of the request). If there is no challenge handler in place the default user id would be anonymous.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • I dont want all device ID's which are registered. I just want device ID at the time of registration event. Means when I click register device at that time. How can I get that in client side. – user3747168 Nov 25 '16 at 07:12
  • I do not believe there is a client-side API for this, AFAIK. Use the REST API afterwards. – Idan Adar Nov 25 '16 at 07:13
  • is there any chance that I get device ID in server adapter side without hitting API? – user3747168 Nov 25 '16 at 07:29
  • For push Notification we need to generate access token which is valid for 1 hour. But there is one API Admin URL which does not need access token. So can that admin API can use in production also in 8.0 or it is deprecated? – user3747168 Nov 25 '16 at 09:52
  • I'm not sure what API you are referring to. – Idan Adar Nov 25 '16 at 10:02
  • http://localhost:9080/mfpadmin/management-apis/2.0/runtimes/mfp/notifications/applications/com.sample.pushnotificationscordova/messages ......this one. – user3747168 Nov 25 '16 at 12:22
  • The response json , to the registerDevice call will contain the deviceid of the registered device – Vivin K Nov 28 '16 at 07:41
  • @VivinK But its not in proper JSON format. So have to split, parse, stringify then I can able to get device id. Is there any other way? – user3747168 Nov 28 '16 at 08:49
  • No. Either this way or use REST API as Idan suggested. Even with REST API's output, you will need to find the right key from the JSON and get the value – Vivin K Nov 28 '16 at 09:40
  • @VivinK ok thnk you – user3747168 Nov 28 '16 at 09:47