Skip to content

Latest commit

 

History

History
69 lines (58 loc) · 1.57 KB

README.md

File metadata and controls

69 lines (58 loc) · 1.57 KB

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);
}