JohannesBauer97 / keycloak-ionic

Keycloak Capacitor Adapter for Ionicframework
https://www.npmjs.com/package/keycloak-ionic
Apache License 2.0
16 stars 19 forks source link

Deviceready has not fired #13

Open lugaru90 opened 3 years ago

lugaru90 commented 3 years ago

Hi All,

Short Problem Description: When the user is logged in automatically at startup, the console fires an error:

deviceready has not fired after 5 seconds. Channel not fired: onDOMContentLoaded

If i disable the automatic login and let the user login manually, the error is gone. But Live Reloading of Capacitor does not fire anymore - so it seems like a related bug.

Configuration as below:

app.component.ts

initializeApp() {
    this.keycloakservice.init();
    App.addListener('appUrlOpen', (data: any) => {
      this.zone.run(() => {
        let slug = data.url.split("REMOVED_PRIVACY").pop();
        if (slug) {
          this.router.navigateByUrl(slug);
        } else {
          this.router.navigate(["/start"])
        }
      });
    });
  }

keycloak.service.ts

init() {
        this.keycloak = Keycloak({
            url: 'REMOVED_PRIVACY',
            realm: 'REMOVED_PRIVACY',
            clientId: 'REMOVED_PRIVACY'
        });

        if (Capacitor.isNativePlatform()) {
            this.keycloak.init({
                adapter: 'capacitor-native',
                responseMode: 'query',
                redirectUri: 'REMOVED_PRIVACY://REMOVED_PRIVACY',
                onLoad: 'check-sso'
            });
        } else {
            this.keycloak.init({
                adapter: 'capacitor-native',
                responseMode: 'query',
                redirectUri: 'http://localhost:8100',
                onLoad: 'check-sso',
                silentCheckSsoRedirectUri: window.location.origin + '/assets/silent-check-sso.html',
            });
        }
    }