Skip to content

Issue when using InAppBrowser in combination with Android Back button #7

Description

@torsorensen

Hi there,

My Setup
I'm running your project on my physical Android device with my own keycloak server.
I've also installed the officially supported Ionic InAppBrowser plugin in order for the user to perform the login "inside my app".

Issue 1, not resolved
When my app loads, it immediately sends me to the keycloak served login page as dictated by the main.ts file.

So far so good. If I don't login but rather use the back button of the Android device, I'm experiencing an issue. It closes the InAppBrowser, and shows no signs of my application except for the tag of the page. I know, because if I change the body's background colour to red using CSS, I see a red page.

I think it's safe to assume that some Android users will click the back button while viewing the Keycloak login page. At the moment, I don't know how to "fix" this, as I cannot find a way to listen for the "close" event of the InAppBrowser. Any help would be appreciated!!

Issue 2, which I can fix
If I then press the back button AGAIN, the app goes to the background (not force-killed). Then, when the app is re-opened, the InAppBrowser is not ready, and the default OS browser opens, so the user doesn't experience opening my app.
I've came around this issue by putting your KeycloakService.init call inside a deviceready callback (main.ts file still):

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log("onDeviceReady");
    initAppWithKeycloak(); //calls the block of code containing the KeycloakService.init() and the Promise callbacks
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions