Search code examples
androidpushibm-mobilefirstuserid

Worklight WL.Client.getUserName


I have a Worklight 6.2 app. I am modifying the android java code to subscribe to a notification sent via Bluemix. After the user logs in, I would like to register the device using the userid that gets created. Is there an API call that I can use within the android code that is the equivalent to WL.Client.getUserName, or should I be calling the java code from my javascript and passing the userName to the java code? Thanks for any suggestions.

JT


Solution

  • There is no Java equivalent to this. This is a Worklight API.

    • What you can do is use the new WL.App.sendActionToNative method in Worklight 6.2 for to send a value to your native code and from there do what you need with it.

      WL.App.sendActionToNative(“doSomething”, { customData: 12345} );  
      

      Where customdData is the WL.Client.getUserName.
      On the native side you then need to use WLActionReciever (see What's New).

    • You could also opt to implement a basic Cordova plug-in that will move data from the web to native view. The tutorial in the Getting Started page is doing exactly that.