IBM Worklight 5.0.6 - Using WebViewOverlay sample code and connectOnStartup don't work together - ibm-mobilefirst

Using the Worklight v5.0.6 code sample/tutorial "Integrating server-generated pages in hybrid applications" (http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v506/WebViewOverlay.zip) allows for the web content to be integrated. The code sample works fine and web content integrated correctly.
However, when I set connectOnStartup to true in the apps//common/js/initOptions.js file, the tabs and web content from the WebViewOverlay fail to load.
I see in the wlclient.js (apps//android/native/assets/www/default/wlclient/js/wlclient.js) that there is a check that if doConnectionOnStartup is true, then call WL.Utils.wlCheckReachability(), else call finalizeInit()
It appears that the WebViewOverlay and the tabs are created by the finalizeInit() being called, but if connectOnStartup is set true, then finalizeInit is not called.
How can I get both the WebViewOverlay to work and the connectOnStartup to work together?

This is, most probably, caused by connection failure. wlCommonInit function will be invoked only after successful connection, in case connection fails it will never be invoked. First of all - check your connectivity from a mobile handset to WL server. Second, you can either manually use WL.Client.connect() after tabbar was initialized (like Carlos suggested) or specify onConnectionFailure callback in your initOptions.

I provided what I did above in the comments - but it turned out that the dialog box to indicate an update was available was not showing up, and instead the error message "WL.SimpleDialog.show() error in invoking callback." was seen in the log messages of logcat. This log message is coming from worklight.js (apps//android/native/assets/www/default/wlclient/js/worklight.js) on line 820. Just FYI, I did change the worklight.js code to print out err, and it said "No class found". I didn't take the troubleshooting any further at that point
So the app was contacting the WL Server correctly, but the dialog to indicate an update was available was not appearing.
To fix, I simply created a new hybrid app and brought over the necessary code to get the WebViewOverlay to work

Related

How to handle user gesture required is required error from browsers

Hello I'm using neodynamic weblientprint to print directly from browser. There's a part that includes a script that detects if the client utility is installed, after which its retrives the printers installed on the system.
However I intermittently get this error when the script runs - Unable to launch 'webclientprintvi: -getPrinters: because a user gesture is required.
I get this error on some client system browsers, while some client systems browsers never show this error. Is there a setting that needs to be configured on the browser. Browsers tests are chrome and edge
Thanks.
I discovered that if you are using the WCPP detection feature, then calling jsWebClientPrint.getPrinters() will produce the "...because a user gesture is required" console error. I had a page that called that method w/o the detection and it worked w/o complaining.
I didn't dive any deeper than that as to determining why the extra embedding detection causes this to happen. I just re-worked the page, calling the method instead on a Refresh button click; which, of course Chrome is then happen with.

MobileFirst App Diagnostic

How can I disable the APP DIAGNOSTIC screenshot after the occurrence of an error ? It appears selecting it on an error POPUP in the app itself. This app is hybrid and based on MobileFirst 7.1.
There is no flag to remove the 'Details' button that appears in the pop-up that leads to this Diagnostics table.
I believe you should be able to override the dialog all-together and provide your own by using the onConnectionFailure property in the initOptions.js file. You should have there the following snippet
// # The callback function to invoke in case application fails to connect to MobileFirst Server
//onConnectionFailure: function (){},

Strange getUserMedia issue?

I'm working on an html application that uses getUserMedia. It works great so far but there is one little problem:
The web application is also being called from local file system. That means file://.
Ok, WebRTC is unavailable in this case. When the Browser tries to call
navigator.getUserMedia({video: true, audio: false}, function(localMediaStream) {...}, function(error) {alert("blabla webrtc unavailable";)});
it should run into an error and call the error callback.
In case of file://, none of these two callbacks will be ever called.
In another case, the web application is running over regular http://, a warning is given, that the WebRTC feature is unavailable in insecure environments, but here the error callback is working as expected.
I need the error callback to tell the user, that WebRTC is unavailable.
What is wrong here?
(It is used for an unimportant feature. And only getUserMedia() is used, not the entire WebRTC-Workflow. But it is ugly, if it run into a blank screen)
And no, there is no waiting popup which ask the user for permission :-)
The problem is Chrome only. Probably a Browser bug?
Thanks.
Silently failing for file:// is documented Chrome behaviour, see here. If you can control Chrome, the allow-file-access-from-files flag enables getUserMedia from file urls.

IBM Worklight 6.2. Change default behavior for Remote disable in native apps

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"

No WCF request is sent from Silverlight on client machine

My SL application is commercial and working just fine on hundreds of machines.
SL is using a WCF service and it works as expected, but today I observed behavior on client machine, where literally no call is made to server.
After you click button that sends a call, some error occures, and no record about WCF call is created in Fiddler.
Error is:
[HttpWebRequest_WebException_RemoteServer]
Arguments: NotFound
Debugging resource strings are unavailable...
I read about this error that people recommend to use Fiddler, but as I say there is no call displayed in Fiddler
So problem is worse than I thought initially.
It comes and goes. Currently we have found a working solution that fixes the problem after it appears although it doesn't make any sense to me.
For example if I get this error in chrome & mozilla & OOB version,
launching a program in IE works, and after that chrome,mozilla & OOB
start to work too.
Thing is that same people who had this problem solved with this workaround experience it again in some days, like a week, with no apparent reason, and then combination of launches from various locations helps (usually IE helps the most).
Any help appreciated, I start a bounty as its pretty sick bug and I need to fix it somehow.
Update
Weird IE fix scenario:
At some point OOB version gets into state where it doesn't send any WCF request to server.
(fiddler doesn't see it, server doesn't gets it).
After launching web version in IE, and hitting the same button, that sends WCF request we get desired result in IE web version.
Without changing anything else, just relaunching OOB version which was in this buggest state before, makes OOB version work correctly. Its not reinstalled, not changed - nothing.
This is what I call "IE cure" of this problem.
So the question is what can IE launch potentiall change for OOB version?
According to this thread the message Debugging resources are unavailable appears when de client is not using the the Silverlight Developer Runtime.
This means that the actual exception is hidden from you (and us) so the next step is to reproduce the error on a system that has the Silverlight Developer Runtime.
I found this article. It might be worth it to check the certificate you are using (are you using a certificate) It is one of those things that is different with OOB apps and browsers.