Xamarin Forms Android activity for re-opening "chrome custom tabs"

134 views Asked by At

We have developed app-A in latest Xamarin Forms for Android and iOS. This problem is on Android only.

  1. In order to log into app-A (Android) we use the WebAuthenticator.AuthenticateAsync to open up "chrome-custom-tabs" with the desired URL.
  2. The user enters credentials on the desired URL and
  3. is then redirected to another authentication app-B (it is the Danish MitID-app) where the user confirms the login.
  4. After this confirmation in app-B the user should be switch back to the "chrome-custom-tabs"-browser opened from app-A for the login-process to finish.
  5. When that process is finish the user is redirected back to app-A using the callBackUri provided to the WebAuthenticator.

However I face a problem in step 4. I have set up an app link that can open app-A and this app link is given to the app-B. The app link opens app-A using this Intent Filer defined in MainActivity.cs in the Android-project

[Activity(Label = "app-A", LaunchMode = LaunchMode.SingleTask, Icon = "@mipmap/ic_launcher", RoundIcon = "@mipmap/ic_launcher_round", Theme = "@style/MainTheme", MainLauncher = false, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, Exported = true)]
[IntentFilter(new[] { Android.Content.Intent.ActionView }, AutoVerify = true,
Categories = new[] { Android.Content.Intent.CategoryDefault, Android.Content.Intent.CategoryBrowsable },
DataScheme = "https", DataHost = "my-url")]
public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
...
}

I understand that the app link "my-url" opens up app-a, but had hoped that the "chrome-custom-tab" would still be open on top of app-A. This how it works on iOS with equivalent configuration using Universal Link.

I believe I should setup an intent-filter on "my-url" starting an activity that will launch (or rather re-open/switch to) the "chrome-custom-tab" that has been opened in step 1. But I don't know how to do this and need your help :) or if you have another solution please bring it forward. Thanks in advance.

0

There are 0 answers