Ejemplo n.º 1
0
    public static bool LoginUser(Action <bool> callback, bool isSilent, bool enableServerAuth = false, bool forceCodeForeRefreshToken = false, List <string> requestedScopes = null)
    {
        LCGoogleLoginBridge.SharedInstance();
        authCallback = callback;
        string[] strScopesArray = null;
        if (requestedScopes == null || requestedScopes.Count <= 0)
        {
            strScopesArray = new string[0];
        }
        else
        {
            strScopesArray = requestedScopes.ToArray();
        }

        if (Application.platform == RuntimePlatform.Android)
        {
            return(LCGoogleLoginAndroid.CallAndroidLoginMethod(LCGoogleLoginAndroid.kUserLogin, isSilent, enableServerAuth,
                                                               forceCodeForeRefreshToken, strScopesArray));
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            int noOfScopes = (strScopesArray == null) ? 0 : strScopesArray.Length;
            return(LCGoogleLoginiOS.userLogin(isSilent, enableServerAuth, forceCodeForeRefreshToken, strScopesArray, noOfScopes));
        }
        else
        {
            if (debugLogs)
            {
                Debug.Log("LCGoogleLogin: LoginUser: Unsupported platform");
            }
        }
        return(false);
    }
Ejemplo n.º 2
0
    public static string GSIRefreshToken()
    {
        LCGoogleLoginBridge.SharedInstance();

        if (Application.platform == RuntimePlatform.Android)
        {
            if (debugLogs)
            {
                Debug.Log("LCGoogleLogin: GSIRefreshToken: Always null for android. Check google docs for why so");
            }
            return(LCGoogleLoginAndroid.CallAndroidStringMethod(LCGoogleLoginAndroid.kStrRefreshToken));
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            return(LCGoogleLoginiOS.refreshToken());
        }
        else
        {
            if (debugLogs)
            {
                Debug.Log("LCGoogleLogin: GSIRefreshToken: Unsupported platform");
            }
        }

        return(null);
    }
Ejemplo n.º 3
0
    public static void InitWithClientID(string clientID)
    {
        if (instance == null)
        {
            instance = FindObjectOfType(typeof(LCGoogleLoginBridge)) as LCGoogleLoginBridge;
            if (instance == null)
            {
                instance = new GameObject("LCGoogleLoginBridge").AddComponent <LCGoogleLoginBridge>();

                if (string.IsNullOrEmpty(clientID))
                {
                    Debug.LogError("LCGoogleLoginBridge: InitWithClientID: Google Web Client ID is required");
                    return;
                }

                if (Application.platform == RuntimePlatform.Android)
                {
                    LCGoogleLoginAndroid.InitiateWithClientID(clientID);
                }
                else if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    LCGoogleLoginiOS.initiateWithClientID(clientID);
                }
                else
                {
                    if (debugLogs)
                    {
                        Debug.Log("LCGoogleLogin: LoginUserBasic: Unsupported platform");
                    }
                }
            }
        }
    }
Ejemplo n.º 4
0
    public void SubmitData()
    {
        DatabaseReference reference = FirebaseDatabase.DefaultInstance.RootReference;

        reference.Child(emailText).Child(LCGoogleLoginBridge.GSIEmail())
        .SetRawJsonValueAsync(JsonConvert.SerializeObject(_AppRequest));
        reference.Child(messageText.text).Child(_AppRequest.message)
        .SetRawJsonValueAsync(JsonConvert.SerializeObject(_AppRequest));
        reference.Child(locationText.text).Child(_AppRequest.location)
        .SetRawJsonValueAsync(JsonConvert.SerializeObject(_AppRequest));


        StorageReference storage = FirebaseStorage.DefaultInstance.RootReference;

        Firebase.Storage.StorageReference img_ref = storage.Child("UserImages/user.jpg");

        ImageGet.instance.imgTex.GetRawTextureData();

        img_ref.PutBytesAsync(ImageGet.instance.imgTex.GetRawTextureData())
        .ContinueWith((System.Threading.Tasks.Task <StorageMetadata> task) => {
            if (task.IsFaulted || task.IsCanceled)
            {
                Debug.Log(task.Exception.ToString());
            }
            else
            {
                Firebase.Storage.StorageMetadata metadata = task.Result;
                string download_url = metadata.DownloadUrl.ToString();
                Debug.Log("Finished uploading...");
                Debug.Log("download url = " + download_url);
            }
        });
    }
Ejemplo n.º 5
0
    public void ManualInit()
    {
        //Keep logging to false in production
        LCGoogleLoginBridge.ChangeLoggingLevel(true);

        //For Android, You need to replace it with web client ID. Check details given in LCGoogleLoginBridge file or ReadMe file or tutorial video
        //For iOS, web client id will be used if you are using server auth. Normal iOS client id is picked up from Google-Services plist file. Its safe to pass null here for iOS if no server auth is used otherwise its ignored by the sdk

        //#warning Pass web client ID & remove this warning
        LCGoogleLoginBridge.InitWithClientID("926983986077-ksdfj7dfaarpca31dfane3ag439kar3l.apps.googleusercontent.com");
        PrintMessage("Google Login Initialized");
    }
Ejemplo n.º 6
0
    public void ManualInit()
    {
        if (!Application.isEditor)
        {
            LCGoogleLoginBridge.ChangeLoggingLevel(true);

            LCGoogleLoginBridge.InitWithClientID("926983986077-ksdfj7dfaarpca31dfane3ag439kar3l.apps.googleusercontent.com");
            infoText1.text = "Manually Initialized".ToString();
        }
        else
        {
            FirebaseCreate("test", "test");
        }
    }
Ejemplo n.º 7
0
    public void SignInServerAuth()
    {
        Action <bool> logInCallBack = (Action <bool>)((loggedIn) => {
            if (loggedIn)
            {
                PrintMessage("Google Login Success> " + LCGoogleLoginBridge.GSIUserName());
            }

            else
            {
                PrintMessage("Google Login Failed");
            }
        });

        LCGoogleLoginBridge.LoginUser(logInCallBack, false, true, false, null);
    }
Ejemplo n.º 8
0
 public void GrantedScopes()
 {
     string[] scopes = LCGoogleLoginBridge.GSIGrantedScopes();
     if (scopes == null || scopes.Length <= 0)
     {
         PrintMessage("GrantedScopes: None");
     }
     else
     {
         string scopeStr = "";
         foreach (string scope in scopes)
         {
             scopeStr += " " + scope;
         }
         PrintMessage("GrantedScopes: " + scopes.Length + scopeStr);
     }
 }
Ejemplo n.º 9
0
    public void SignInNormal()
    {
        Action <bool> logInCallBack = (Action <bool>)((loggedIn) => {
            if (loggedIn)
            {
                //PrintMessage("Google Login Success> " + LCGoogleLoginBridge.GSIUserName());
                infoText1.text = "logged in true".ToString();

                FirebaseCreate(LCGoogleLoginBridge.GSIEmail(), "123456");
            }

            else
            {
                infoText1.text = "logged in false".ToString();
            }
        });

        LCGoogleLoginBridge.LoginUser(logInCallBack, false);
    }
Ejemplo n.º 10
0
    public static bool LogoutUser()
    {
        LCGoogleLoginBridge.SharedInstance();

        if (Application.platform == RuntimePlatform.Android)
        {
            return(LCGoogleLoginAndroid.CallAndroidBoolMethod(LCGoogleLoginAndroid.kUserLogout));
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            return(LCGoogleLoginiOS.userLogout());
        }
        else
        {
            if (debugLogs)
            {
                Debug.Log("LCGoogleLogin: LogoutUser: Unsupported platform");
            }
        }
        return(false);
    }
Ejemplo n.º 11
0
    public static string GSIServerAuthCode()
    {
        LCGoogleLoginBridge.SharedInstance();

        if (Application.platform == RuntimePlatform.Android)
        {
            return(LCGoogleLoginAndroid.CallAndroidStringMethod(LCGoogleLoginAndroid.kStrServerAuthCode));
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            return(LCGoogleLoginiOS.serverAuthCode());
        }
        else
        {
            if (debugLogs)
            {
                Debug.Log("LCGoogleLogin: GSIIDUserToken: Unsupported platform");
            }
        }

        return(null);
    }
Ejemplo n.º 12
0
    public void SignInDriveNoServer()
    {
        Action <bool> logInCallBack = (Action <bool>)((loggedIn) => {
            if (loggedIn)
            {
                PrintMessage("Google Login Drive Success> " + LCGoogleLoginBridge.GSIUserName());
            }

            else
            {
                PrintMessage("Google Login Drive Failed");
            }
        });

        //Scopes : https://developers.google.com/identity/protocols/googlescopes
        LCGoogleLoginBridge.LoginUser(logInCallBack, false, false, false,
                                      new List <string>()
        {
            "https://www.googleapis.com/auth/drive.readonly",
            "https://www.googleapis.com/auth/drive.photos.readonly"
        });
    }
Ejemplo n.º 13
0
    public static string GSIEmail()
    {
        LCGoogleLoginBridge.SharedInstance();

        if (Application.platform == RuntimePlatform.Android)
        {
            return(LCGoogleLoginAndroid.CallAndroidStringMethod(LCGoogleLoginAndroid.kStrUserEmail));
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            return(LCGoogleLoginiOS.userEmail());
        }
        else
        {
            if (debugLogs)
            {
                Debug.Log("LCGoogleLogin: GSIPhotoUrl: Unsupported platform");
            }
        }

        return(null);
    }
Ejemplo n.º 14
0
    static bool ChangeLoggingDevLevel(bool enabled)
    {
        LCGoogleLoginBridge.SharedInstance();

        if (Application.platform == RuntimePlatform.Android)
        {
            return(LCGoogleLoginAndroid.CallAndroidInBoolMethod(LCGoogleLoginAndroid.kInBoolChangeDevLogLevel, enabled));
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            LCGoogleLoginiOS.changeDevLogLevel(enabled);
            return(true);
        }
        else
        {
            if (debugLogs)
            {
                Debug.Log("LCGoogleLogin: ChangeLoggingDevLevel: Unsupported platform");
            }
        }

        return(false);
    }
Ejemplo n.º 15
0
    public static string[] GSIGrantedScopes()
    {
        LCGoogleLoginBridge.SharedInstance();

        if (Application.platform == RuntimePlatform.Android)
        {
            return(LCGoogleLoginAndroid.CallAndroidStringArrayMethod(LCGoogleLoginAndroid.kStrArrScopes));
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            IntPtr scopesArray = LCGoogleLoginiOS.avalableScopes();
            int    noScopes    = LCGoogleLoginiOS.noOfAvalableScopes();
            return(LCGoogleLoginiOS.GetCListFromiOSNativeSentData(scopesArray, noScopes));
        }
        else
        {
            if (debugLogs)
            {
                Debug.Log("LCGoogleLogin: GSIGrantedScopes: Unsupported platform");
            }
        }

        return(null);
    }
Ejemplo n.º 16
0
 public void UserToken()
 {
     PrintMessage("UserToken: " + LCGoogleLoginBridge.GSIIDUserToken());
 }
Ejemplo n.º 17
0
 public void SignOut()
 {
     LCGoogleLoginBridge.LogoutUser();
     PrintMessage("Logout Done");
 }
Ejemplo n.º 18
0
 public void ChangeLogging(bool enable)
 {
     logsEnabled = enable;
     LCGoogleLoginBridge.ChangeLoggingLevel(enable);
     PrintMessage("ChangeLogging: " + enable);
 }
Ejemplo n.º 19
0
 //If you are trying to use additional capabilities like server side APIs, you need to pass this will be returned.
 //Read more about it ServerAuthCode in google docs because very few developers actually need this
 public void ServerAuthCode()
 {
     PrintMessage("ServerAuthCode: " + LCGoogleLoginBridge.GSIServerAuthCode());
 }
Ejemplo n.º 20
0
 public void RefreshToken()
 {
     PrintMessage("RefreshToken: " + LCGoogleLoginBridge.GSIRefreshToken() + AdditionalAndroidOnlyNotes());
 }
Ejemplo n.º 21
0
 public void AccessToken()
 {
     PrintMessage("AccessToken: " + LCGoogleLoginBridge.GSIAccessToken() + AdditionalAndroidOnlyNotes());
 }
Ejemplo n.º 22
0
 public void UserEmail()
 {
     PrintMessage("UserEmail: " + LCGoogleLoginBridge.GSIEmail());
 }
Ejemplo n.º 23
0
 public void PhotoUrl()
 {
     PrintMessage("PhotoUrl: " + LCGoogleLoginBridge.GSIPhotoUrl());
 }
Ejemplo n.º 24
0
 public void UserName()
 {
     PrintMessage("UserName: " + LCGoogleLoginBridge.GSIUserName());
 }