diff --git a/Assets/GeneratedLocalRepo/GoogleSignIn.meta b/Assets/GeneratedLocalRepo/GoogleSignIn.meta new file mode 100644 index 00000000..643c8739 --- /dev/null +++ b/Assets/GeneratedLocalRepo/GoogleSignIn.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b61eac07f531e47e88cb1c85e60babc6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GeneratedLocalRepo/GoogleSignIn/Editor.meta b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor.meta new file mode 100644 index 00000000..812eac9e --- /dev/null +++ b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c16b20c7b99db475489e77f362251cbe +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository.meta b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository.meta new file mode 100644 index 00000000..40037936 --- /dev/null +++ b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 960ff195b2d264bc697a5dba72bc5cea +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com.meta b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com.meta new file mode 100644 index 00000000..53d0f7ae --- /dev/null +++ b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4821c989d637949378393334e79d94a1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google.meta b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google.meta new file mode 100644 index 00000000..681b5810 --- /dev/null +++ b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: adc50d30a9f79444e857d456b84e536d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin.meta b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin.meta new file mode 100644 index 00000000..92ab697f --- /dev/null +++ b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 07ae6524bae3c4593b168df0584bcdf9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support.meta b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support.meta new file mode 100644 index 00000000..cfe8fae2 --- /dev/null +++ b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dcd8478414f51478c848c7730799a176 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4.meta b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4.meta new file mode 100644 index 00000000..73feaa22 --- /dev/null +++ b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 64ab3e0d886b64f7a85e205a2f9c3d11 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.aar b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.aar new file mode 100644 index 00000000..1ebd5a13 Binary files /dev/null and b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.aar differ diff --git a/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.aar.meta b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.aar.meta new file mode 100644 index 00000000..dc67ba2a --- /dev/null +++ b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.aar.meta @@ -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: diff --git a/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.pom b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.pom new file mode 100644 index 00000000..1ccd2def --- /dev/null +++ b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.pom @@ -0,0 +1,8 @@ + + + 4.0.0 + com.google.signin + google-signin-support + 1.0.4 + aar + \ No newline at end of file diff --git a/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.pom.meta b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.pom.meta new file mode 100644 index 00000000..28142fcd --- /dev/null +++ b/Assets/GeneratedLocalRepo/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.4/google-signin-support-1.0.4.pom.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8a24c3856f4a64bab94b41358576a027 +labels: +- gpsr +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml b/Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml index 625d2e51..89c7983e 100644 --- a/Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml +++ b/Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml @@ -3,7 +3,7 @@ - + extra-google-m2repository @@ -12,7 +12,7 @@ - diff --git a/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.h b/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.h index 5e77bc10..953e3350 100644 --- a/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.h +++ b/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.h @@ -14,7 +14,26 @@ * limitations under the License. */ #import -@interface GoogleSignInHandler - : NSObject +#import + +@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 diff --git a/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.mm b/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.mm index 9b82a370..15822032 100644 --- a/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.mm +++ b/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.mm @@ -18,6 +18,9 @@ #import #import #import +#import + +#import "UnityInterface.h" #import @@ -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) { diff --git a/Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm b/Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm index 33631489..66d92c21 100644 --- a/Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm +++ b/Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm @@ -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