如何在 Xamarin.Android 应用上集成新的 Google 登录? [英] How do you integrate the new Google Sign-In on a Xamarin.Android app?
问题描述
我正在尝试按照 Google 的说明操作将新的 Google 登录(不是旧的 Google+ 登录)添加到我的 Xamarin.Android 应用程序.在我的一生中,我找不到支持新登录系统的正确 Google Play 服务 NuGet 包或 Xamarin 组件.
I am attempting to follow Google's instructions on how to add the new Google Sign-In (not the old Google+ Sign-In) to my Xamarin.Android app. For the life of me, I cannot find the correct Google Play Services NuGet package or Xamarin component that supports the new sign-in system.
当我将以下代码添加到 Activity 时,我收到找不到类型或命名空间‘GoogleSignInOptions’.您是否缺少程序集引用?"构建错误.
When I add the following code to the activity, I get "The type or namespace 'GoogleSignInOptions' could not be found. Are you missing an assembly reference?" build error.
// Configure sign-in to request the user's ID, email address, and basic
// profile. ID and basic profile are included in DEFAULT_SIGN_IN.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build();
以下是项目中包含的 Xamarin.GooglePlayServices NuGet 包:
Here are the Xamarin.GooglePlayServices NuGet packages that are include in the project:
<package id="Xamarin.GooglePlayServices.Ads" version="27.0.0.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Analytics" version="27.0.0.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.AppIndexing" version="27.0.0.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Base" version="27.0.0.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Basement" version="27.0.0.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Identity" version="27.0.0.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Location" version="27.0.0.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Maps" version="27.0.0.0" targetFramework="MonoAndroid50" />
<package id="Xamarin.GooglePlayServices.Plus" version="27.0.0.0" targetFramework="MonoAndroid50" />
Xamarin 尚不支持新的 Google 登录系统还是我遗漏了什么?
Is the new Google Sign-In system not yet supported on Xamarin or am I missing something?
推荐答案
启用预发布 nugets 并搜索:
Xamarin.GooglePlayServices.Identity 29.0.0-beta1
packages.config:
<packages>
<package id="Xamarin.Android.Support.v4" version="23.1.1.0" targetFramework="MonoAndroid44" />
<package id="Xamarin.GooglePlayServices.Auth" version="29.0.0-beta1" targetFramework="MonoAndroid44" />
<package id="Xamarin.GooglePlayServices.Base" version="29.0.0-beta1" targetFramework="MonoAndroid44" />
<package id="Xamarin.GooglePlayServices.Basement" version="29.0.0-beta1" targetFramework="MonoAndroid44" />
<package id="Xamarin.GooglePlayServices.Identity" version="29.0.0-beta1" targetFramework="MonoAndroid44" />
</packages>
C# 版本的将 Google 登录集成到您的 Android 应用程序中>
SignInButton button = FindViewById<SignInButton> (Resource.Id.sign_in_button);
gso = new GoogleSignInOptions.Builder (GoogleSignInOptions.DefaultSignIn)
.RequestEmail ()
.Build ();
mGoogleApiClient = new GoogleApiClient.Builder (this)
.EnableAutoManage(mLoginFragment, failedHandler)
.AddApi (Auth.GOOGLE_SIGN_IN_API)
.Build ();
button.Click += delegate {
signIn();
};
这篇关于如何在 Xamarin.Android 应用上集成新的 Google 登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!