Skip to content

A set of tools for Unity to allow handling Google Sign-in for Android and iOS.

License

Notifications You must be signed in to change notification settings

kidsstar/GoogleSigninPlugin-for-Unity

 
 

Repository files navigation

GoogleSigninPlugin

A set of tools for Unity to allow handling Google Sign-in for Android and iOS.

Install

GoogleSigninPlugin.unitypackage

Settings

Create settings file

  • Menu/Settings/Google

Android

  • Setting ClientId and ClientSecret to GoogleSettings.asset

iOS

  • Setting ClientId and UrlScheme to GoogleSettings.asset

Editor

  • Setting ClientId and ClientSecret to GoogleSettings.asset

Usage

using GoogleSignIn;

Example: Sign-in

Call the "SignIn" method and check the items you want to get.

public IEnumerator Example()
{
  yield return GoogleSigninPlugin.Instance.SignIn(
    requestEmail:true,
    requestId:true,
    requestIdToken:true,
    requestServerAuthCode:true,
    requestProfile:true);
   
  Debug.Log(GoogleSigninPlugin.Instance.Email);
  Debug.Log(GoogleSigninPlugin.Instance.Id);
  Debug.Log(GoogleSigninPlugin.Instance.IdToken);
  Debug.Log(GoogleSigninPlugin.Instance.ServerAuthCode);
  Debug.Log(GoogleSigninPlugin.Instance.DisplayName);
}

Example: Sign-out

public void Example()
{
  GoogleSigninPlugin.Instance.SignOut();
}

AndroidManifest.xml

Replace main Activity.

<!--
<activity android:name="com.unity3d.player.UnityPlayerActivity" ...
-->
<activity android:name="com.hiyorin.googlesignin.CustomUnityPlayerActivity" ...

When using your own main Activity

Please pass the value of OnActivityResult of your Activity

public void Exapmle(int requestCode, int resultCode, AndroidJavaObject data)
{
  GoogleSigninPlugin.Instance.AndroidActivityResult(requestCode, resultCode, data);
}

About

A set of tools for Unity to allow handling Google Sign-in for Android and iOS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 62.6%
  • Java 24.4%
  • Objective-C++ 12.2%
  • Objective-C 0.8%