[英]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. 我正在Xamarin.Forms应用程序中实现身份验证。 I was looking at this sample " TodoAWSAuth - Configuring Google as an OAuth identity provider ".
我正在查看此示例“ TodoAWSAuth - 将Google配置为OAuth身份提供商 ”。 In my implementation of OAuthLoginPresenter specific for android I have this code: using Xamarin.Auth;
在我的特定于android的OAuthLoginPresenter的实现中我有这个代码:使用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' 参数1:无法从'object'转换为'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 同样在Xamarin文档中,代码是相同的: Xamarin.Auth文档
Thanks to all 谢谢大家
*Edit: The API below has probably changed with Xamarin.Auth 1.5. *编辑:下面的API可能已经改变了Xamarin.Auth 1.5。 See moljac's answer.
见moljac的答案。
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: 对我来说,我正在使用活动来启动登录页面并传入上下文,但我也在
ContentPage
渲染器的OnElementChanged()
方法中运行以下代码:
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.Auth 1.4.x支持自定义选项卡和SafariViewController,但没有Xamarin.Forms支持大多数用户想要的。 Xamarin.Forms support is in the 1.5.0-alpha soon to be released.
Xamarin.Forms支持即将发布1.5.0-alpha。
Samples extracted from the repo: 从回购中提取的样品:
https://github.com/moljac/Xamarin.Auth.Samples.NugetReferences https://github.com/moljac/Xamarin.Auth.Samples.NugetReferences
ComicBook is Xamarin.Forms 漫画书是Xamarin.Forms
Providers Traditional/Standard 提供者传统/标准
Those will give you idea how to do it. 那些会让你知道如何做到这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.