Essentials: [Bug] WebAuthenticator - Android - Custom Tab remains in the foreground after forwaring result to the app

Created on 8 Jun 2020  路  4Comments  路  Source: xamarin/Essentials

Description

When using Firefox as the default browser on Android, the Custom tab remains in the foreground after redirected to the app using custom data scheme and response is properly handled with data available in WebAuthenticatorResult.

NOTE: Using IdentityServer4 for the backend.

Steps to Reproduce

  1. Set Firefox as browser app on Android (tested version 68.8.1)
  2. Perform call to WebAuthenticator.AuthenticateAsync using configured Android app and backend server.
  3. Complete sign-in in the Custom tab.

Expected Behavior

Custom tab is closed and MainActivity is back in foregeound.

Actual Behavior

App handles callback in WebAuthenticationCallbackActivity but custom tab remains in the foreground.

Basic Information

  • Version with issue: 1.5.3.2
  • Last known good version: N/A
  • IDE: N/A
  • Platform Target Frameworks:

    • iOS: N/A

    • Android: 9.0 - API 28

    • UWP: N/A

  • Android Support Library Version: N/A
  • Nuget Packages: Xamarin.Forms 4.6.0.847
  • Affected Devices: LG G7
bug

Most helpful comment

I've experienced this issue in every browser I've tried. Samsung's, Edge, Chrome, Firefox. On Android 8, 9, and 10. On XF 4.7. Any update on where this is at? This bug completely breaks web authentication since there is no redirect back to the app.

All 4 comments

I have similar problems with Mi browser

I've experienced this issue in every browser I've tried. Samsung's, Edge, Chrome, Firefox. On Android 8, 9, and 10. On XF 4.7. Any update on where this is at? This bug completely breaks web authentication since there is no redirect back to the app.

Try to override OnCreate method of your WebAuthenticatorCallbackActivity like this:

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            new Task(() => {
                StartActivity(new Intent(Application.Context, typeof(MainActivity)));
            }).Start();
        }

I've experienced this issue in every browser I've tried. Samsung's, Edge, Chrome, Firefox. On Android 8, 9, and 10. On XF 4.7. Any update on where this is at? This bug completely breaks web authentication since there is no redirect back to the app.

I do experience the same issue with Samsung's browser and Firefox but Chrome works fine for me. The only issue I've found with Chrome is that it somehow keeps its session active across app restarts, meaning it doesn't prompt for username/password until the session expires. That's another issue, though.

Was this page helpful?
0 / 5 - 0 ratings