Close native mobile app after user logs out

1
I have created a native mobile app (for both Android and Apple). This makes use of SSO with SAML. When the user logs out (using a microflow) in the native mobile app , we cancel the session, log out in SAML using the in-app browser, and then we redirect the user to an empty page with only a link to log in again (via SAML). If the user now uses his "back" button from this logged-out page, he will end up in the last page where he was before logging out. After the user does an action, he is redirected to the login page (which redirects to SAML). Can we close the app from a microflow? Or make sure the app closes when the user chooses the "back" button on the phone from the logged-out page?
asked
4 answers
2

Hi,

We have solved it as follows: after logging off the session in a microflow, a page is opened. This contains a HTML snippet and a JavaScript snippet.

The HTML snippet contains the following:

<script type="text/javascript" src="cordova.js"></script>

The JavaScript snippet contains the following:

try{

    var oauthLogout = function() {
    var oauthWindow = cordova.InAppBrowser.open("about:blank", "_blank", "location=no,toolbar=no,clearcache=yes,clearsessioncache=yes");
        var exitFn = function(){
            oauthWindow.removeEventListener("exit", exitFn);
            navigator.app.exitApp();
        };
        oauthWindow.addEventListener("exit", exitFn);
        var cb = function(event) {
                oauthWindow.removeEventListener("loadstop", cb);

                oauthWindow.executeScript({
                    code: "console.log('yay');"
                }, function(){
                    console.log('Opruimen succesvol');
                    mx.logout();
                    oauthWindow.close();
                });
        }
        oauthWindow.addEventListener("loadstop", cb);
    }

    oauthLogout();

}catch(e){
    console.log(e.message);
}

This closes our mobile app

Best regards

Diederik

answered
1

HI Diederik,

I am also planning to implement SSO for native mobile app, can you please suggest me how you are able to achieve that or any links to docs?

Appreciate your response

answered
0

Hi Diederik,

I have to use SAML with Mendix Native Mobile. However, I cannot find any document or example on this topic. If you did it, can you tell me how you did it or which document you used?

Best regards,
Gamze

answered
-1

Have you tried

 navigator.app.exitApp()

See stackoverflow

https://stackoverflow.com/questions/8738587/how-to-use-navigator-app-exitapp-to-exit-application-in-phone-gap

Regards,

Ronald

 

answered