Worklight 6.2.0
Native Worklight App on Samsung Galaxy S4, Android 4.4.2
WLAnalytics.enable();
WLAnalytics.log("some text", new org.json.JSONOBject() );
WLAnalytics.send();
// and also go on to successfully call an adapter
Analytics Dasboard shows the app version and adapter activity. Log Search does not show any application log messages and the dropdown for selecting applications shows "All Applications" only, no sign of my app.
Have I missed some initialisation step? Any other ideas?
** edited to add **
It has been suggested that we should use the method:
WLAnalytics.log("some text");
In our 6.2.0.00 CLI environment there is no such Java method.
The answer is that there a further initialisation requirement that seems to be necessary when working with a pure Native application, these are typically build using the Worklight CLI tooling.
This is the initialisation, note the call to Logger.setContext()
WLAnalytics.enable();
Logger.setContext(this);
Then this works
WLAnalytics.log("My test message2", new org.json.JSONObject());
It's worth noting that the call to WLAnalytics.send() is not necessary in normal running as typically the analytic data is buffered and sent as a piggy-back on adapter calls. However while testing a call to send() does help.
Further, if running in an environment where the Analytics WAR is on a separate machine from the Worklight Server WAR there are additional latencies. Hence testing all of this needs care.
For now, I suggest that you just use the WLAnalytics.log(String) method. There are some clear inconsistencies that need to be dealt with whether it be through documentation or code fixes.
The WL.Logger APIs were originally created to send log data to a custom adapter, which is why they take a dictionary/object for extra metadata. The data sent to the custom adapter could be read as a valid JSON object to run operations on the adapter.
The WL.Analytics APIs mimicked the WL.Logger APIs for the same purpose: parsing the JSON on a worklight adapter. The Operational analytics server came as a convenience to intercept and display some of these logs, but not all of them are being captured as you have learned.
Your questions are all valid though, as none of this is described in the documentation. In future releases, we may make use of the extra JSON object passed into the API in the Operational analytics console, but for right now they only serve their original purpose of sending the analytics to a custom adapter.
Related
I am using android studio for developing my android app. SO i created a native API using the worklight 7.1.0 and copied all the jar files to the lib folder and wlclient.properties to the asset folder. So after that i have a set of adapter deployed in my company server, which i have to invoke from native code. So i changed all the values in the wlclient.properties as per the adapter required to call.
I added a listener for the connect and tried connect , it gave a Unexpected error.
I added a listener for invoking the adapter and tried connect, it gave a Application is not found in the server, couldnt register client
You only provided your explanation, and not any real example... so that's not helping to understand the real culprit here.
What I can say is:
So i changed all the values in the wlclient.properties as per the adapter required to call.
What you put in wlclient.properties is the server address for the client application to connect to. It does not relate to the adapter per-se. The adapter is invoked by the server once a request from the client came in.
The adapter then sends a request to what that is defined in the connectionPolicy element of its {adaptername}.xml file.
Various exceptions
Since you did not provide anything useful that can be debugged - I suggest that you will instead review the following tutorial and its sample application: https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-1/foundation/server-side-development-category/invoking-adapter-procedures-native-android-applications/
The tutorial mentions the required steps to take in order to use the MobileFirst API in the Android app.
Am new to IBM Worklight,Is there a way to fetch the call Log and contact,like in android using TelephonyManager to track call duration,call details.Can any one know,please guide me to do fetch these details.
Worklight itself does not have access to this information. However, Worklight uses Cordova, and using Cordova you could gain this access.
To accomplish the above, you will need to create a Cordova plug-in, from which you will be able to hook into the TelephonyManager and retrieve any information that it can provide you, including call duration and details.
Creating a Cordova plug-in cannot be explained shortly, so I will link you to the training module explaining exactly this: Adding native functionality to hybrid applications with Apache Cordova.
Also, in the following question I have code written that enables hooking to the TelephonyMananger to get a different type of information, so you should be able to modify it to get what you need: IBM Worklight - Unable to get network signal strength in Android
As I understand it, a Worklight JSONStore is only available to hybrid Worklight applications.
Correction: A Worklight JSONStore is available to both hybrid and native applications as of Worklight 6.2. My mistake.
For either type of application, under what application upgrade circumstances would the data in it be permanently lost? For example, I see at least three variations of upgrade:
Upgrade using Direct Update - I would assume the contents of the JSONStore will be kept as-is in these circumstances.
Complete deletion of the application followed by installation of the new version - I would assume the content of the JSONStore would be completely lost in these circumstances.
Binary upgrade of the application from AppCenter / App Store / Play Store / MDM solution / etc. - In this case, will the JSONStore continue to exist between one version and the next with the same data?
Worklight JSONStore is available for Hybrid applications and also for Native applications (starting Worklight 6.2).
Per the JSONStore documentation:
Reliable Storage means that your data is not deleted unless one of the
following events occurs:
The application is removed from the device.
One of the methods that removes data is called.
To cover your mentioned cases:
Direct Update: JSONStore data remains as-is (unless your update triggers code that will cause code deletion...)
Deletion of application: this will remove the application and any associated data, including JSONStore
Application update: this will not remove the JSONStore
I'm using worklight application management features from an Android native App.
I want that when in the console the application status is changed to "Access Disabled" the only option for the user will be to quit.
In the Knowledge Center and in Developer works there is documentation about how to do it:
http://www-01.ibm.com/support/knowledgecenter/SSZH4A_6.2.0/com.ibm.worklight.appadmin.doc/admin/t_denying_access_to_older_app_versions.html?lang=en
https://www.ibm.com/developerworks/community/blogs/worklight/entry/how_to_create_a_customized_remote_disable_behavior?lang=en
It is explained that you must set a specific value for the initOptions object used in the WL.Client.init() method.
But in the Android native API I have not found the way to set the initOptions. The init method is deprecated and it does not accept initOptions.
Also, in case of Remote Disable the ResponseListener used in the WLClient.connect(aResponseListener) is not invoked, success or failure, no method is executed. Is this working as designed? I would expect a failure or success but not nothing.
Is it possible in a native app to force the application to close in case of Remote Disable?
How could I handle this situation manually in the app?
Unfortunately I do not have an example for you, but this is the general idea.
See if you can work with it (if someone can produce an example - please do...):
You need to create your own Remote Disable challenge handler that will extend the default Worklight Remote Disable challenge handler (RemoteDisableChallengeHandler.java).
class MyRemoteDisableChallengeHandler extends WLRemoteDisableChallengeHandler
Then you need to implement your custom logic in MyRemoteDisableChallengeHandler
WLClient.registerChallengeHander(new MyRemoteDisableChallengeHandler())
This will override the original.
You'll need to create your own dialog with a Quit button.
Some additional documentation.
For handling MaM configurations, this is, when you configure the app as Lost, Stolen, etc, in the Worklight Console -> Devices tab you must install the Fix IF201408281937 (Worklight 6.2) or later.
This events are also handled with the ChallengeHandler registered for the realm "wl_remoteDisableRealm"
I have a Adobe Flash Builder GUI application that connects to Red5 to communicate.
can i use the red5 to call facebook API calls? can anyone provide an example? all the examples that i can find are with tomcat.
thanks!
Unfortunately they can't.
facebook-java-api cannot work with red5 because it requires the session data that does not pass into red5 and uses variables that i received only by a java Servlet.
there is also a facebook java api called TinyFbClient (www.socialjava.com).
this client is small, very easy to understand with very nice examples.
here i didn't have to use sessions, but i do need to get the uid of the user i want to query on. the client side can forward that information when needed.
TinyFbClient depends on jersey (http://download.java.net/maven/2/com/sun/jersey/) but unfortunately jersy does not compile on red5 properly. if you'll try to use the binary version you'll just get the error
java.lang.ClassNotFoundException: com.sun.ws.rs.ext.RuntimeDelegateImpl
and that is because the compiled binary cannot operate properly.
I resolved the issue by installing tomcat and allowing the user to connect to tomcat first, with tomcat i fetch the session and the relevant facebook data, stores it in a database and then with red5 i manipulate the data as needed.
hopefully this information will be found useful.
update
i had the previous error message because i did not copy the relevant jars (jersey and jsr311) to the red5 directory. unfortunately it did not solve the problem.
i tried different versions of jersey (1.0.x,1.1.x,1.2). the code did compile but any calls to a facebook api would just stop the application.
i decided to do the facebook information fetching part in tomcat and then to deliver it to red5.
Yes, it can work in Red5. Especially if you had it working in Tomcat, since we provide an embedded Tomcat server.