Xamarin.ios Google SignIn将当前用户返回为空
我在Xamarin iOS应用程序中使用google登录,但是在出现的safari浏览器提示符中成功输入用户名和密码后,它将属性CurrentUser返回为null 我的代码:Xamarin.ios Google SignIn将当前用户返回为空,xamarin.ios,xamarin.forms,google-signin,Xamarin.ios,Xamarin.forms,Google Signin,我在Xamarin iOS应用程序中使用google登录,但是在出现的safari浏览器提示符中成功输入用户名和密码后,它将属性CurrentUser返回为null 我的代码: Google.SignIn.SignIn.SharedInstance.Delegate = this; Google.SignIn.SignIn.SharedInstance.UIDelegate = this; Google.SignIn.SignIn.SharedInstance.SignInUser();
Google.SignIn.SignIn.SharedInstance.Delegate = this;
Google.SignIn.SignIn.SharedInstance.UIDelegate = this;
Google.SignIn.SignIn.SharedInstance.SignInUser();
Google.SignIn.SignIn.SharedInstance.SignedIn += SharedInstance_SignedIn;
private void SharedInstance_SignedIn(object sender, SignInDelegateEventArgs e)
{
var signin = (Google.SignIn.SignIn)sender;
//Here if i debug signin variable, its property CurrentUser comes as null
}
我正在使用
Xamarin.IOS.Google.Signin:v4.0.1.1
我是否缺少一些需要在Google api控制台中启用的设置?发送方指示引发事件的类
要获取用户,您可以使用e.User或Google.SignIn.SignIn.SharedInstance.CurrentUser
解释方法符号的功能
Sign-In SDK自动获取访问令牌,但只有在调用SignIn或Signingly方法时才会刷新访问令牌
好的,如果我添加触发SharedInstance\u SignedIn事件的Google.SignIn.SignIn.SharedInstance.signUser,我将获得CurrentUser。但是如果我不添加Google.sign.sign.SharedInstance.SignInUser,它不会触发event@NathanN您有问题吗?是否需要Google.SignIn.SignIn.SharedInstance.signUser才能触发SharedInstance\u SignedIn事件?在我的例子中,只有当我添加上面的代码行时,事件才会被触发。我看不到源代码,但我认为是的。由于每次登录时都需要访问令牌,因此除非调用RefreshAccessToken方法,否则您需要刷新它,因此如果您不持续调用SignInUser或SignInUse,它将在连接中失败,并且不会触发回调方法。非常感谢。我还有一个问题,Xamarin.Ios.GooglePlus是否有类似的回调方法用于登录?