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

Uncaught (in promise): TypeError: Cannot read property 'addListener' of undefined #10

Closed bamaas closed 3 years ago

bamaas commented 3 years ago

Hi,

I'm trying to implement keycloak with ionic (angular) but facing issues to get this thing to work. I tried to follow the includes example in the repo but I guess I'm just missing something stupid simple.

I let the app check wether the user is logged in or not, if not the login method is called.But this throws a Uncaught (in promise): TypeError: Cannot read property 'addListener' of undefined image

Any idea what I am missing here? The full source code can be found here: https://github.com/bamaas/FullStackFit/blob/ionic-keycloak/frontend/src/app/app.component.ts

Thank you.

JohannesBauer97 commented 3 years ago

Hi,

when you use capacitor-native as adapter, Capacitor must be available when running the project. Capacitor is not available if you run your project for web(-browser) ng start. Capacitor is available when you run your project as an iOS app on the simulator.

To get it work with ng start you could just remove the adapter: 'capacitor-native' line or code a switch.