Search code examples
ibm-mobilefirst

Pass URL with Notifying


I am wondering if it possible to configure the remote notify option to pass a URL.

I see there is a function for onErrorRemoteDisableDenial. I tried to modify it, but it seems to disables the app. Even if i put code to continue, the next call to the backend does not work.

But what we are looking for is giving the user the option to update via URL, or just continue with the app version they currently have.

Using Worklight 6.1


Solution

  • There is a way to customize both Remote Disable and Remote Notify, but the downloadLink (the link that you've set in Worklight Console) is available only when setting Remote Disable, not Remote Notify. Only the message (the text set in Worklight Console) will be available.

    You can customize the Remote Notify flow by using the following in main.js (outside of any function):

    wl_remoteDisableChallengeHandler.handleChallenge = function(message,downloadLink) {
        WL.SimpleDialog.show(
            "New Version",
            message, 
            [
             {text: "Download", handler: function() {
                 // Maybe use WL.App.openURL(downloadLink) to go to the app store
             }},
             {text: "Close", handler: function() {
                 // Continue with the app
             }}
            ]);
    };
    

    wl_remoteDisableChallengeHandler.handleChallenge overrides the default Remote Notify code path. wl_remoteDisableChallengeHandler.handleFailure will override the default Remote Disable code path (and this is another way to customize Remote Disable).

    Edit: per the findings in the comments, in order to get both the message and downloadLink, you will first need to temporary set Remote Disable and then change to Remote Notify, this is a workaround because Remote Notify by default is not meant to also pass the downloadLink to the default provided dialog.

    Note: Remote Notify is meant to be displayed only once per a message's life cycle, so after it was displayed - it will not be displayed again until a the message is set again in the console.

    A way to get the code to work on each application launch is to clear the application's HTML local storage (at some point while the app is running), where a "flag" is stored to tell the application not to display the message again (I forgot its name, but you could print the contents of the local storage and debug that).

    Sounds like a nice feature request: https://developer.ibm.com/mobilefirstplatform/help