简体   繁体   中英

Xamarin.forms cannot convert from object to system.type with Xamarin.Auth and specific android platform

I'm implementing authentication in a Xamarin.Forms app. I was looking at this sample " TodoAWSAuth - Configuring Google as an OAuth identity provider ". In my implementation of OAuthLoginPresenter specific for android I have this code: using Xamarin.Auth;

 namespace InstagramApp.Droid
 {
   public class OAuthLoginPresenter
   {
      public void Login(Authenticator authenticator)
      {
        Xamarin.Forms.Forms.Context.StartActivity(authenticator.GetUI(Xamarin.Forms.Forms.Context));
      }
   }
 }

My:

Xamarin.Forms.Forms.Context.StartActivity(authenticator.GetUI(Xamarin.Forms.Forms.Context));

returns me:

Argument 1: cannot convert from 'object' to 'System.Type'

It is the same of the sample in the link. What could be the problem?

Also in the Xamarin Documentation the code is the same: Xamarin.Auth documentation

Thanks to all

*Edit: The API below has probably changed with Xamarin.Auth 1.5. See moljac's answer.

For me, I am using the activity to start the login page and to pass in the context, but I am also running the code below from within a ContentPage renderer's OnElementChanged() method:

Android.App.Activity activity = Context as Android.App.Activity;

//Initialize authenticator

activity.StartActivity(auth.GetUI(activity));

Xamarin.Auth 1.4.x supports Custom Tabs and SafariViewController, but no Xamarin.Forms support what most of the users want. Xamarin.Forms support is in the 1.5.0-alpha soon to be released.

Samples extracted from the repo:

https://github.com/moljac/Xamarin.Auth.Samples.NugetReferences

ComicBook is Xamarin.Forms

Providers Traditional/Standard

Those will give you idea how to do it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM