Capacitori Keycloak Login

Does anyone know how to implement a Keycloak Login with Capacitor?
I tried to use Capacitor as the Keycloak Adapter and used a deeplink to redirect into the app after a successful login. It’s working the first time you login but safari stays opened in the background with the keycloak page opened. On the next app start the redirect into the app or back to login is not working and i only see a blank screen. I think it’s because the safari is still opened with the previous keycloak page if i close this page and start the app it’s working again.

The same code is working on android without problems.