xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.53k stars 506 forks source link

[Bug] WebAuthenticator/Android - user case scenario when WebAuthenticator opens external Chrome and does not return to app #2110

Closed ideveloperaz closed 7 months ago

ideveloperaz commented 8 months ago

Hello,

We have OAuth and use WebAuthenticator to help us get web access token from custom ID Server if doing login and logout in app like normally then everything ok and WebAuthenticator opens browser in app ... but when we login then close(kill) app, then open app again do logout - we could see external chrome is opening and could redirect back to app, but when we do login then WebAuthenticator also opens external chrome and I see that app proceed after WebAuthenticator.AuthenticateAsync() BUT opened external chrome is not closed and does not open app ... it just stays on that Chrome login page, but app in background continue working as expected after WebAuthenticator.AuthenticateAsync()

this happens only for Android

Steps to Reproduce

pls see in description

Expected Behavior

could open back app after login, during that special user case scenario

Actual Behavior

could not open app back and stays on external Chrome browser login page (though app in background proceeds like expected)

Basic Information

Samidarex commented 7 months ago

Hi @ideveloperaz, have you considered adding "launchMode: SingleTask" into your main activity? Also are you using intent-filters which will handle the callback from the custom chrome tabs?

If not here's an example of an intent filter that might help you:

[IntentFilter( new[] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable }, DataScheme = "https", // Replace with your actual scheme DataHost = "test.com" // Replace with your actual host )];

I hope this proves helpful in resolving your issue.

ideveloperaz commented 7 months ago

Hi @Samidarex

Thank you for your help ... yes launchMode: SingleTask did the work ... we had launchMode: SingleInstance before .. and that is exactly where SingleTask differs from SingleInstance!

I'm just wondering why documents do not say anything about that !?!?

ideveloperaz commented 7 months ago

thank you a lot! case solved!