IBM Worklight - How to hide the HTML page in a Hybrid app and load native page instead?

575 Views Asked by At

I am developing a hybrid app and my first page is native page in both android and ios. I kept initial html page as blank white background and loading native page by using the WL.nativePage.show API method.

I am able to go to native page but after the splash screen, it's showing a white screen which is my HTML page for a while then the native pages is displayed. So I want to avoid that white screen. How to do that?

My code for showing native is:

function wlCommonInit() {
     WL.NativePage.show('ProductHomeViewController', backFromNativePage, params);
}
1

There are 1 best solutions below

3
On

This is not easily doable in Worklight 6.1, but is likely to be improved in a later release.

  • In Android, you can change in AndroidManifest.xml the default activity the application starts with that of yours (the activity you have created for your Native Page)
  • In iOS, you can start another UIViewController from CDVMainViewController

The above will help to have a Hybrid app that its "start page" (the page you see after the splash image) is a native page, HOWEVER, this will not help in sharing the session between the Hybrid and Native pages (as explained in the answer to this question by you).

There is work in progress to create a Cordova plug-in that will allow session sharing between hybrid and native pages when the native page is the starting page of the application; it is not yet ready. As I wrote at the top, in a future release all of this should work better.


To address the questions in the comments:

The Hybrid application also contains that same Native API as a Native application would, this means that once you launch the app and navigate to a native page after the splash image (based on the above), you can still use the same native API methods to connect to the Worklight Server, invoke Worklight Adapters, etc.

The problem is still the sharing of the cookies (session) between the native webview and the hybrid webview.

Again, as written above, there is work in progress to create a Cordova plug-in that will allow session sharing between hybrid and native pages when the native page is the starting page of the application; it is not yet ready. In a future release all of this should work better.