I have developed a hybrid sample app on MobileFirst Platform 7.0. When I make any change in the .html file, direct update won't appear on the client mobile application (Android and iOS). Am I missing something? I have already deployed the .wlapp file on the server.
Direct Update will only work if the application connects to the server. Make sure that you are using the API method WL.Client.connect(), otherwise even if deploying an updated .wlapp to the server, the update will not be received in the application.
You say you haven't updated the .wlapp; you should. The Direct Update process works by fetching updated web content (HTML/CSS/JS/etc.) from inside the .wlapp. As Idan says, you also need to make sure your client is connecting to the server.
In order to begin communicating with MobileFirst Server you need to call WL.Client.connect() API method once the application start.
For Example in a main.js file :
WL.Client.connect({
onSuccess: function(){
console.log("App is connected to the server...");
// Call some methods ...
},
onFailure: function(){
alert("unable to connect to the server...");
}
});
Make sure that you have built the .wlapp file with the correct configuration(Deployment target) and that's deployed successfully in the server.
Related
Details of Project :
Application Framework - Ionic V3.0
IBM MobileFirst server(devKit) - Product version: 8.0.0.00-20170911-123510
Application Mobilefirst version -
config.xml -
mfp:platformVersion -8.0.0.00-20170218-003050
plugin name="cordova-plugin-mfp" spec="8.0.2017021815"
It's working fine in android. But in IOS, after finishing of soft update, application screen goes blank (black screen). After killing and restart of application, it's started working fine.
I have implement Direct update feature in mobilefirst 8 application as below :
// Direct Update - Used to trigger a request to the MobileFirst Server, to check for updated web resources.
WLAuthorizationManager.obtainAccessToken()
.then(
function () {
console.log("*** Obtained token successfully.");
},
function () {
console.log("*** Failed obtaining token.");
}
);
Reference : https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/application-development/direct-update/#secure-direct-update
This is perhaps has to do with the fact that Ionic now uses the WKWebView by default. See https://ionicframework.com/docs/wkwebview/
And it is a known limitation with MobileFirst Direct update on the WKWebview. See https://mobilefirstplatform.ibmcloud.com/tutorials/en/foundation/8.0/product-overview/release-notes/known-issues-limitations/#wkwebview-support-for-ios-cordova-applications
As mentioned in the above link, use the wkwebview-engine-localhost plugin to ensure Direct update continues to work.
It's fixed in latest IBM MobileFirst version.
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.
Created a simple hybrid app. Only have the following in the code
main.js
function wlCommonInit() {
WL.Client.connect({
onSuccess: function() {alert ("OK");},
onFailure: function (string) {alert ("fail" + string);}
});
}
I created a mobile web environment.
After I did a Build All Environment, Run it on the Server.
I right click on the mobile web environment > Preview
I kept getting a pop up alert saying "Access Denied" with a button named reload
I moved to my iphone and in the safari, typed in the URL for the mobile web. I got exactly the same error on my iphone.
Please assist.
You haven't told us what version of MobileFirst Platform Foundation you are using, but I am guessing that it is 7.1.
In 7.1, a new Session-Independent Mode was introduced, and is turned on by default. However, session-independent mode is not supported in browser-based environments (such as mobile web). If you try to use an app that's configured for session-independent mode in an environment that doesn't support it, you will get this error. If you want to create an app in 7.1 that uses a browser-based environment, you'll need to disable session-independent mode.
If you go into your project's "worklight.properties" file, set (or change) these values:
mfp.session.independent=false
mfp.attrStore.type=HttpSession
and then rebuild/deploy your project, it should work.
Please see the doc page I've linked above for further information about session-independent mode.
I want to develop on my Windows machine and push my changes to an iPad (iOS 7.1.2) test device via direct update. This worked for me in WL 6.1, but since my update to WL 6.2 I'm having some issues. Following scenario describes my problem.
Create new WL project and add iPad as environment
Enabled worklightSettings in application-descriptor.xml
Add the code snippet below to main.js
Run on Worklight Development Server
Open project in Xcode via eclipse
Clean project in Xcode and run on iPad
Make a change, re-deploy and verify Direct Update is received
Copy the project to a Windows machine and open in eclipse
Run on Worklight Development Server on Windows machine
Open the app settings via Settings.app and enable use Custom Server URL
Replace the IP of your mac by the IP of your windows machine
On windows: Make a change and re-deploy
Restart the app on the iPad
The moment I restart my app I get the following exception in my In the worklight development server console on my Windows machine:
[WARNING ] SRVE0190E: File not found: //apps/services/api/HelloDirectUpdate/ipad/init
[ERROR ] FWLSE0048E: Unhandled exception caught: SRVE0190E: File not found: //apps/services/api/HelloDirectUpdate/ipad/init
When I modify the custom server URL and I remove the last slash, I get the message that an update is available. But when I click update the progress bar in the downloading popup doesn't move. My Windows machine and MAC both have the following WL Studio version: platformVersion="6.2.0.00.20140724-2139". What am I doing wrong?
main.js
function wlCommonInit(){
WL.Client.connect({
onSuccess: onConnectSuccess,
onFailure: onConnectFailure
});
}
function onConnectSuccess() {
WL.Logger.debug("Connect success.");
}
function onConnectFailure() {
WL.Logger.debug("Connect failed.");
}
This is indeed a defect in Worklight 6.2.
On the one hand, as you mention in your reproduction steps you need to remove the forweawrd slash from the custom server URL in order to be able to connect to the Worklight Server (because otherwise there are 2 slashes in the URL and it fails connecting).
On the other hand, the client requires this forward slash.
You can see this in Wireshark:
Bad: GET /test3directUpdate/test3/iphone/1.0?skin=default HTTP/1.1
Good: GET /test3/directUpdate/test3/iphone/1.0?skin=default HTTP/1.1
I've opened a defect for this; you will need to create a PMR in order to receive a fix, once available (or wait until it is publicly available via IBM Fix Central / Eclipse Marketplace).
I am loading a jsp or server side application using worklight webview (super.loadUrl("hostname:port/Myapplciation",false)). My question is will cordova related functionality work since its inside WL webview. If it doesn't work what is the actually reason because I had read that WL hybrid application runs inside a webview and cordova works there.
Thanks
yes, it will work.
(adding some more text to make answer at least 30 chars long so it can be submitted)
I don't have a working environment to try it out in, but my suspicion is that getting the JS files from either location should work, but that getting them from the device would be preferred because then you wouldn't have a cache miss and a remote download, and you wouldn't need to host them on the remote server.