0
votes

I am developing a project, in which i need to call a native page in wlCommonInit()

function wlCommonInit(){
    WL.NativePage.show(nativePageClassName, backFromNativePage, params);
}

I want my project to receive the direct update with persession mode. So to connect with the Mobile First Server, I have called WL.Client.connect()

function wlCommonInit(){
    busyind = new WL.BusyIndicator;
    busyind.show();
    WL.Client.connect({onSuccess: connectSuccess, onFailure: connectFail});
    WL.NativePage.show(nativePageClassName, backFromNativePage, params);
}

More over I want to handle the direct update so I have added the required code.

wl_directUpdateChallengeHandler.handleDirectUpdate = function(directUpdateData,
  directUpdateContext) {
  // custom WL.SimpleDialog for Direct Update
  var customDialogTitle = 'Custom Title Text';
  var customDialogMessage = 'Custom Message Text';
  var customButtonText1 = 'Update Application';
  var customButtonText2 = 'Not Now';
  WL.SimpleDialog.show(customDialogTitle, customDialogMessage, [{
      text: customButtonText1,
      handler: function() {
          directUpdateContext.start(directUpdateCustomListener);
      }
  }, {
      text: customButtonText2,
      handler: function() {
          wl_directUpdateChallengeHandler.submitFailure();
      }
  }]);
};

var directUpdateCustomListener = {
    onStart: function(totalSize) {},
    onProgress: function(status, totalSize, completeSize) {},
    onFinish: function(status) {
      WL.SimpleDialog.show('New Update Available', 'Press reload button to update to new version', [{
          text: WL.ClientMessages.reload,
          handler: WL.Client.reloadApp
      }]);
  }
};

Here the problem is, the application is navigating to the native page before it can go to the direct update handler function when the direct update is available.

Is there any way to resolve it?

1

1 Answers

0
votes

I think what you should do instead if use the API [WL.Client.checkForDirectUpdate.

This way you will have the ability to first check for direct update - handle it if there is an update and then execute the function for opening the native page.

The code that is running is async, so you can't control it if you're not following the above suggestion.