Added the new updated google sign in

main-FireBaseAuth
Hazim Bin Ijaz 1 month ago
parent ce3b0ea590
commit 971b7c664d

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b61eac07f531e47e88cb1c85e60babc6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c16b20c7b99db475489e77f362251cbe
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 960ff195b2d264bc697a5dba72bc5cea
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4821c989d637949378393334e79d94a1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: adc50d30a9f79444e857d456b84e536d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 07ae6524bae3c4593b168df0584bcdf9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dcd8478414f51478c848c7730799a176
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 64ab3e0d886b64f7a85e205a2f9c3d11
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,29 @@
fileFormatVersion: 2
guid: 46650e32098084cf396dadb158f1a4df
labels:
- gpsr
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 1
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.signin</groupId>
<artifactId>google-signin-support</artifactId>
<version>1.0.4</version>
<packaging>aar</packaging>
</project>

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 8a24c3856f4a64bab94b41358576a027
labels:
- gpsr
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

@ -3,7 +3,7 @@
<!-- See https://github.com/googlesamples/unity-jar-resolver#usage for
how to configure dependencies -->
<androidPackages>
<androidPackage spec="com.google.android.gms:play-services-auth:16+">
<androidPackage spec="com.google.android.gms:play-services-auth:20+">
<androidSdkPackageIds>
<androidSdkPackageId>extra-google-m2repository</androidSdkPackageId>
</androidSdkPackageIds>
@ -12,7 +12,7 @@
<!-- iOS Cocoapod dependencies can be specified by each iosPod element. -->
<iosPods>
<iosPod name="GoogleSignIn" version=">= 4.0.2" bitcodeEnabled="false"
<iosPod name="GoogleSignIn" version="~> 6.0.2" bitcodeEnabled="false"
minTargetSdk="6.0">
</iosPod>
</iosPods>

@ -14,7 +14,26 @@
* limitations under the License.
*/
#import <GoogleSignIn/GIDSignIn.h>
@interface GoogleSignInHandler
: NSObject <GIDSignInDelegate, GIDSignInUIDelegate>
#import <GoogleSignIn/GIDConfiguration.h>
@interface GoogleSignInHandler : NSObject
{
@public
GIDConfiguration* signInConfiguration;
@public
NSString* loginHint;
@public
NSMutableArray* additionalScopes;
}
@property(class, nonatomic, readonly) GoogleSignInHandler *sharedInstance;
- (void)signIn:(GIDSignIn *)signIn dismissViewController:(UIViewController *)viewController;
- (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)_error;
- (void)signIn:(GIDSignIn *)signIn didDisconnectWithUser:(GIDGoogleUser *)user withError:(NSError *)_error;
@end

@ -18,6 +18,9 @@
#import <GoogleSignIn/GIDGoogleUser.h>
#import <GoogleSignIn/GIDProfileData.h>
#import <GoogleSignIn/GIDSignIn.h>
#import <UnityAppController.h>
#import "UnityInterface.h"
#import <memory>
@ -59,6 +62,19 @@ NSRecursiveLock *resultLock = [NSRecursiveLock alloc];
@implementation GoogleSignInHandler
GIDConfiguration* signInConfiguration = nil;
NSString* loginHint = nil;
NSMutableArray* additionalScopes = nil;
+ (GoogleSignInHandler *)sharedInstance {
static dispatch_once_t once;
static GoogleSignInHandler *sharedInstance;
dispatch_once(&once, ^{
sharedInstance = [self alloc];
});
return sharedInstance;
}
/**
* Overload the presenting of the UI so we can pause the Unity player.
*/
@ -105,9 +121,6 @@ NSRecursiveLock *resultLock = [NSRecursiveLock alloc];
case kGIDSignInErrorCodeKeychain:
currentResult_->result_code = kStatusCodeInternalError;
break;
case kGIDSignInErrorCodeNoSignInHandlersInstalled:
currentResult_->result_code = kStatusCodeDeveloperError;
break;
case kGIDSignInErrorCodeHasNoAuthInKeychain:
currentResult_->result_code = kStatusCodeError;
break;
@ -146,6 +159,7 @@ NSRecursiveLock *resultLock = [NSRecursiveLock alloc];
* The parameters are intended to be primative, easy to marshall.
*/
extern "C" {
/**
* This method does nothing in the iOS implementation. It is here
* to make the API uniform between Android and iOS.
@ -168,31 +182,29 @@ bool GoogleSignIn_Configure(void *unused, bool useGameSignIn,
bool requestIdToken, bool hidePopups,
const char **additionalScopes, int scopeCount,
const char *accountName) {
if (webClientId) {
[GIDSignIn sharedInstance].serverClientID =
[NSString stringWithUTF8String:webClientId];
}
[GIDSignIn sharedInstance].shouldFetchBasicProfile = true;
int scopeSize = scopeCount;
if (scopeSize) {
NSMutableArray *tmpary =
[[NSMutableArray alloc] initWithCapacity:scopeSize];
for (int i = 0; i < scopeCount; i++) {
[tmpary addObject:[NSString stringWithUTF8String:additionalScopes[i]]];
NSString *path = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
NSString *clientId = [dict objectForKey:@"CLIENT_ID"];
GIDConfiguration* config = [[GIDConfiguration alloc] initWithClientID:clientId];
if (webClientId) {
config = [[GIDConfiguration alloc] initWithClientID:clientId serverClientID:[NSString stringWithUTF8String:webClientId]];
}
[GoogleSignInHandler sharedInstance]->signInConfiguration = config;
int scopeSize = scopeCount;
if (scopeSize) {
NSMutableArray *tmpary = [[NSMutableArray alloc] initWithCapacity:scopeSize];
for (int i = 0; i < scopeCount; i++) {
[tmpary addObject:[NSString stringWithUTF8String:additionalScopes[i]]];
}
[GoogleSignInHandler sharedInstance]->additionalScopes = tmpary;
}
[GIDSignIn sharedInstance].scopes = tmpary;
}
if (accountName) {
[GIDSignIn sharedInstance].loginHint =
[NSString stringWithUTF8String:accountName];
}
if (accountName) {
[GoogleSignInHandler sharedInstance]->loginHint = [NSString stringWithUTF8String:accountName];
}
return !useGameSignIn;
return !useGameSignIn;
}
/**
@ -226,7 +238,12 @@ static SignInResult *startSignIn() {
void *GoogleSignIn_SignIn() {
SignInResult *result = startSignIn();
if (!result) {
[[GIDSignIn sharedInstance] signIn];
[[GIDSignIn sharedInstance] signInWithConfiguration:[GoogleSignInHandler sharedInstance]->signInConfiguration
presentingViewController:UnityGetGLViewController()
hint:[GoogleSignInHandler sharedInstance]->loginHint
callback:^(GIDGoogleUser *user, NSError *error) {
[[GoogleSignInHandler sharedInstance] signIn:[GIDSignIn sharedInstance] didSignInForUser:user withError:error];
}];
result = currentResult_.get();
}
return result;
@ -239,7 +256,9 @@ void *GoogleSignIn_SignIn() {
void *GoogleSignIn_SignInSilently() {
SignInResult *result = startSignIn();
if (!result) {
[[GIDSignIn sharedInstance] signInSilently];
[[GIDSignIn sharedInstance] restorePreviousSignInWithCallback:^(GIDGoogleUser *user, NSError *error) {
[[GoogleSignInHandler sharedInstance] signIn:[GIDSignIn sharedInstance] didSignInForUser:user withError:error];
}];
result = currentResult_.get();
}
return result;
@ -252,7 +271,9 @@ void GoogleSignIn_Signout() {
void GoogleSignIn_Disconnect() {
GIDSignIn *signIn = [GIDSignIn sharedInstance];
[signIn disconnect];
[signIn disconnectWithCallback:^(NSError *error) {
[[GoogleSignInHandler sharedInstance] signIn:[GIDSignIn sharedInstance] didDisconnectWithUser:nil withError:error];
}];
}
bool GoogleSignIn_Pending(SignInResult *result) {

@ -59,29 +59,9 @@ GoogleSignInHandler *gsiHandler;
method_exchangeImplementations(original, swizzled);
}
- (BOOL)GoogleSignInAppController:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// IMPORTANT: IF you are not supplying a GoogleService-Info.plist in your
// project that contains the client id, you need to set the client id here.
NSString *path = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info"
ofType:@"plist"];
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
NSString *clientId = [dict objectForKey:@"CLIENT_ID"];
gsiHandler = [GoogleSignInHandler alloc];
// Setup the Sign-In instance.
GIDSignIn *signIn = [GIDSignIn sharedInstance];
signIn.clientID = clientId;
signIn.uiDelegate = gsiHandler;
signIn.delegate = gsiHandler;
// looks like it's just calling itself, but the implementations were swapped
// so we're actually calling the original once we're done
return [self GoogleSignInAppController:application
didFinishLaunchingWithOptions:launchOptions];
- (BOOL)GoogleSignInAppController:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(@"GSI application:didFinishLaunchingWithOption:");
return [self GoogleSignInAppController:application didFinishLaunchingWithOptions:launchOptions];
}
/**
@ -95,11 +75,8 @@ GoogleSignInHandler *gsiHandler;
openURL:url
sourceApplication:sourceApplication
annotation:annotation];
return [[GIDSignIn sharedInstance] handleURL:url
sourceApplication:sourceApplication
annotation:annotation] ||
handled;
NSLog(@"GSI application:openURL:sourceApplication:annotation: %s", [url.absoluteString UTF8String]);
return [[GIDSignIn sharedInstance] handleURL:url] || handled;
}
/**
@ -108,17 +85,9 @@ GoogleSignInHandler *gsiHandler;
- (BOOL)GoogleSignInAppController:(UIApplication *)app
openURL:(NSURL *)url
options:(NSDictionary *)options {
BOOL handled =
[self GoogleSignInAppController:app openURL:url options:options];
return [[GIDSignIn sharedInstance]
handleURL:url
sourceApplication:
options[UIApplicationOpenURLOptionsSourceApplicationKey]
annotation:
options[UIApplicationOpenURLOptionsAnnotationKey]] ||
handled;
BOOL handled = [self GoogleSignInAppController:app openURL:url options:options];
NSLog(@"GSI application:openURL:options: %s", [url.absoluteString UTF8String]);
return [[GIDSignIn sharedInstance] handleURL:url] || handled;
}
@end

Loading…
Cancel
Save