Skip to content

Commit eb2eb85

Browse files
Implement support for multiple Google Sign-in platforms
1 parent dca98ed commit eb2eb85

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,6 @@ public static void StartXboxOneSession(string xbox_user_token, Action<LootLocker
454454
/// <summary>
455455
/// Start a Game session for a Google User
456456
/// The Google sign in platform must be enabled in the web console for this to work.
457-
/// A game can support multiple platforms, but it is recommended that a build only supports one platform.
458457
/// </summary>
459458
/// <param name="idToken">The Id Token from google sign in</param>
460459
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerSessionResponse</param>
@@ -478,6 +477,39 @@ public static void StartGoogleSession(string idToken, Action<LootLockerGoogleSes
478477
onComplete(response);
479478
});
480479
}
480+
481+
/// <summary>
482+
/// Start a Game session for a Google User
483+
/// The Google sign in platform must be enabled in the web console for this to work.
484+
/// Desired Google platform also must be configured under advanced options in the web console.
485+
/// </summary>
486+
/// <param name="idToken">The Id Token from google sign in</param>
487+
/// <param name="googlePlatform">Google OAuth2 ClientID platform</param>
488+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerSessionResponse</param>
489+
public static void StartGoogleSession(string idToken, GooglePlatform googlePlatform, Action<LootLockerGoogleSessionResponse> onComplete)
490+
{
491+
if (!CheckInitialized(true))
492+
{
493+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerGoogleSessionResponse>());
494+
return;
495+
}
496+
497+
CurrentPlatform.Set(Platforms.Google);
498+
499+
var sessionRequest = new LootLockerGoogleSignInWithPlatformSessionRequest(idToken)
500+
{
501+
platform = googlePlatform.ToString()
502+
};
503+
504+
LootLockerAPIManager.GoogleSession(sessionRequest, response =>
505+
{
506+
if (!response.success)
507+
{
508+
CurrentPlatform.Reset();
509+
}
510+
onComplete(response);
511+
});
512+
}
481513

482514
/// <summary>
483515
/// Refresh a previous session signed in with Google.

Runtime/Game/Requests/LootLockerSessionRequest.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,21 @@ public LootLockerGoogleSignInSessionRequest(string id_token)
182182
this.id_token = id_token;
183183
}
184184
}
185+
186+
public enum GooglePlatform
187+
{
188+
web, android, ios, desktop
189+
}
190+
191+
public class LootLockerGoogleSignInWithPlatformSessionRequest : LootLockerGoogleSignInSessionRequest
192+
{
193+
public string platform { get; set; }
194+
195+
public LootLockerGoogleSignInWithPlatformSessionRequest(string id_token) : base(id_token)
196+
{
197+
this.id_token = id_token;
198+
}
199+
}
185200

186201
public class LootLockerGoogleRefreshSessionRequest : LootLockerGetRequest
187202
{

0 commit comments

Comments
 (0)