4

I follow guide enter link description here

I have a issue when I done login my google account it show toast

enter image description here

And browser not auto close to back my.

Thanks!

Vermoric Huynh
  • 203
  • 2
  • 9

3 Answers3

10

In you CustomUrlSchemeInterceptorActivity page replace inside OnCreate.

        base.OnCreate(savedInstanceState);          
        global::Android.Net.Uri uri_android = Intent.Data;

        Uri uri_netfx = new Uri(uri_android.ToString());

        // load redirect_url Page
        AuthenticationState.Authenticator.OnPageLoading(uri_netfx);

        var intent = new Intent(this, typeof(MainActivity));
        intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
        StartActivity(intent);

        this.Finish();

        return;
Vibhav Patil
  • 123
  • 1
  • 8
  • 2
    Worked great. The only other thing I had to do to make this "perfect" is adding global::Xamarin.Auth.CustomTabsConfiguration.CustomTabsClosingMessage = null; to my Android main activity after the Auth init. Which eliminates that useless toast message – Peter Webb Aug 02 '18 at 23:12
3

This is the warning message shown in the toast.

We can make it null by adding a piece of code in MainActivity just after initializing Xamarin.Auth.

CustomTabsConfiguration.CustomTabsClosingMessage = null;

And for closing the CustomTab login screen and navigating back to your app, set the LaunchMode of your Custom URL activity to SingleTask.

LaunchMode = LaunchMode.SingleTask

Hope this will help.

timiTao
  • 1,417
  • 3
  • 20
  • 34
Blockies
  • 61
  • 7
  • In my Xamarin forms app where do I set the LaunchMode for this tab? My MainActivity is already using LaunchMode.SingleTask and the tab is not closing. – Gilles Apr 13 '18 at 12:55
  • set this in your intent filter activity [Activity(Label = "GoogleAuthInterceptor", LaunchMode = LaunchMode.SingleTask)] – Nick Kovalsky Feb 26 '19 at 20:32
  • This does not work properly when I tested it. App resumes focus, but the window is still there in the background when the application close down. LaunchMode is set to SingleTask and ActivityFlags to ClearTop and SingleTop. – Atle S Jul 10 '19 at 13:06
2

Worked for me as well in avoiding the toast: global::Xamarin.Auth.CustomTabsConfiguration.CustomTabsClosingMessage = null

Tien Duong
  • 2,517
  • 1
  • 10
  • 27
MChase
  • 21
  • 1