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 505 forks source link

Web Authenticator not returning back to App in Android 12, when user sharing(Intent.ActionSend) #2081

Closed DharunAR closed 1 year ago

DharunAR commented 1 year ago

Description:

We developed a mobile app, where users can share documents and pictures from Mobile App.

When user shares a picture/document with our Mobile App, the app will ask the user to log in. We are using WebAuthenticator to login and logout from our app.

Once the login has been made, from the browser it is not redirected back to the APP. We found it is happening only on Android devices, and when we are sharing, the Intent action will be Intent.ActionSend

Steps to Reproduce

  1. Create a sample content page with a button(let's call it as login button).
  2. In MainActivity.cs -> Add a code to support sharing -> [[IntentFilter(new[] { Intent.ActionSend }, Categories = new[] { Intent.CategoryDefault }, DataMimeTypes = new[] {
    "image/", "image/bmp", "image/jpg", "image/png", "text/plain", "application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.image", "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "application/pdf", "application/vnd.ms-powerpoint", "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.template", "video/", "video/mp4"

    })]]
  3. On login button click, add a code for the web authenticator something like the below: [ await WebAuthenticator.AuthenticateAsync(new WebAuthenticatorOptions { Url = new Uri($"{_baseUrl}/auth/mobile"), CallbackUrl = new Uri("trimapp://") });]
  4. Open your gallery, share any image -> Select the app you have developed. It will show an login button
  5. Click on the login button -> Web authenticator will take you to the chrome browser to login to the app.
  6. After the successful login, it is not getting redirected to the APP.

Expected Behavior

App should be redirected without any issues.

Actual Behavior

App stays in browser page, but in background i can see the Application instance got opened, but the redirection was not happening.

Basic Information

ekeneduru commented 1 year ago

Any solution for this

jfversluis commented 1 year ago

This might be fixed by https://github.com/xamarin/Essentials/pull/2090 would you be able to try the resulting NuGet package from that PR?