diff --git a/.gitignore b/.gitignore index 20168e73..3856f369 100644 --- a/.gitignore +++ b/.gitignore @@ -15,12 +15,16 @@ Library/ ProjectSettings/ Temp/ obj/ +Logs/ +Packages/ # Don't check in the resolver GoogleSignInPlugin/Assets/PlayServicesResolver/ +PlayServicesResolver.meta # don't checkin client plists GoogleSignInPlugin/Assets/Plugins/iOS/client*.plist* +GoogleService-Info.plist* Assembly-CSharp-Editor.csproj Assembly-CSharp.csproj @@ -31,3 +35,6 @@ staging/native/google-signin-cpp # don't check in iOS pod generated content contents.xcworkspacedata staging/native/testapp/testapp.xcodeproj/project.xcworkspace/xcuserdata + +# osx +.DS_Store diff --git a/GoogleSignInPlugin/Assets/GoogleSignIn/Editor/UnityEditorPostProcessor.cs b/GoogleSignInPlugin/Assets/GoogleSignIn/Editor/UnityEditorPostProcessor.cs new file mode 100644 index 00000000..ac402fa1 --- /dev/null +++ b/GoogleSignInPlugin/Assets/GoogleSignIn/Editor/UnityEditorPostProcessor.cs @@ -0,0 +1,49 @@ +using System.IO; + +using UnityEditor; +using UnityEditor.Callbacks; +using UnityEditor.iOS.Xcode; + +namespace Google { + public static class UnityEditorPostProessorForSignin { + const string PLIST_FILE_NAME= "GoogleService-Info.plist"; + [PostProcessBuild] + public static void OnPostProcessBuild(BuildTarget buildTarget, string path) + { + // Go get pbxproj file + string projPath = path + "/Unity-iPhone.xcodeproj/project.pbxproj"; + + // PBXProject class represents a project build settings file, + // here is how to read that in. + PBXProject proj = new PBXProject (); + proj.ReadFromFile (projPath); + + // This is the Xcode target in the generated project + string target = proj.TargetGuidByName ("Unity-iPhone"); + + string[] files = Directory.GetFiles("Assets", PLIST_FILE_NAME, SearchOption.AllDirectories); + if (files.Length > 0) { + // Copy plist from the project folder to the build folder + FileUtil.CopyFileOrDirectory (files[0], Path.Combine(path, PLIST_FILE_NAME)); + proj.AddFileToBuild (target, proj.AddFile(PLIST_FILE_NAME, PLIST_FILE_NAME)); + + // add URLType + var plistPath = Path.Combine(path, "Info.plist"); + var plistCred = new PlistDocument(); + plistCred.ReadFromFile(files[0]); + var plistInfo = new PlistDocument(); + plistInfo.ReadFromFile(plistPath); + var urlentry = plistInfo.root.CreateArray("CFBundleURLTypes") + .AddDict(); + urlentry.SetString("CFBundleTypeRole", "Editor"); + urlentry.CreateArray("CFBundleURLSchemes").AddString( + plistCred.root["REVERSED_CLIENT_ID"].AsString() + ); + plistInfo.WriteToFile(plistPath); + + // Write PBXProject object back to the file + proj.WriteToFile (projPath); + } + } + } +} diff --git a/GoogleSignInPlugin/Assets/GoogleSignIn/Editor/UnityEditorPostProcessor.cs.meta b/GoogleSignInPlugin/Assets/GoogleSignIn/Editor/UnityEditorPostProcessor.cs.meta new file mode 100644 index 00000000..41166df1 --- /dev/null +++ b/GoogleSignInPlugin/Assets/GoogleSignIn/Editor/UnityEditorPostProcessor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e2e7d3fdaa15642f795db208da6b0581 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/GoogleSignInPlugin/Assets/GoogleSignIn/GoogleSignIn.cs b/GoogleSignInPlugin/Assets/GoogleSignIn/GoogleSignIn.cs index c59ced72..7a225972 100644 --- a/GoogleSignInPlugin/Assets/GoogleSignIn/GoogleSignIn.cs +++ b/GoogleSignInPlugin/Assets/GoogleSignIn/GoogleSignIn.cs @@ -121,6 +121,10 @@ public Task SignIn() { return tcs.Task; } + public bool SignInCanBeSilent { + get { return impl.SignInCanBeSilent; } + } + /// Starts the silent authentication process. /// /// The authenication process is started and will attempt to sign in without @@ -195,6 +199,7 @@ public GoogleSignInStatusCode Status { internal interface ISignInImpl { Future SignIn(); Future SignInSilently(); + bool SignInCanBeSilent { get; } void EnableDebugLogging(bool flag); void SignOut(); void Disconnect(); diff --git a/GoogleSignInPlugin/Assets/GoogleSignIn/Impl/GoogleSignInImpl.cs b/GoogleSignInPlugin/Assets/GoogleSignIn/Impl/GoogleSignInImpl.cs index 78c8081f..499799c9 100644 --- a/GoogleSignInPlugin/Assets/GoogleSignIn/Impl/GoogleSignInImpl.cs +++ b/GoogleSignInPlugin/Assets/GoogleSignIn/Impl/GoogleSignInImpl.cs @@ -66,6 +66,12 @@ public Future SignIn() { return new Future(new NativeFuture(nativeFuture)); } + public bool SignInCanBeSilent { + get { + return GoogleSignIn_CanBeSilent(SelfPtr()); + } + } + /// /// Starts the authentication process. /// @@ -133,6 +139,9 @@ static extern bool GoogleSignIn_Configure(HandleRef self, [DllImport(DllName)] internal static extern bool GoogleSignIn_Pending(HandleRef self); + [DllImport(DllName)] + internal static extern bool GoogleSignIn_CanBeSilent(HandleRef self); + [DllImport(DllName)] internal static extern IntPtr GoogleSignIn_Result(HandleRef self); diff --git a/GoogleSignInPlugin/Assets/Parse/Plugins/Unity.Tasks.dll b/GoogleSignInPlugin/Assets/Parse/Plugins/Unity.Tasks.dll deleted file mode 100644 index a3a564f3..00000000 Binary files a/GoogleSignInPlugin/Assets/Parse/Plugins/Unity.Tasks.dll and /dev/null differ diff --git a/GoogleSignInPlugin/Assets/Parse/Plugins/Unity.Tasks.dll.meta b/GoogleSignInPlugin/Assets/Parse/Plugins/Unity.Tasks.dll.meta deleted file mode 100644 index a141b679..00000000 --- a/GoogleSignInPlugin/Assets/Parse/Plugins/Unity.Tasks.dll.meta +++ /dev/null @@ -1,36 +0,0 @@ -fileFormatVersion: 2 -guid: af535f85bedbe4425b5153ac2087c75e -labels: -- gvh -timeCreated: 1500403332 -licenseType: Pro -PluginImporter: - serializedVersion: 2 - iconMap: {} - executionOrder: {} - isPreloaded: 0 - isOverridable: 0 - platformData: - data: - first: - Any: - second: - enabled: 1 - settings: {} - data: - first: - Editor: Editor - second: - enabled: 0 - settings: - DefaultValueInitialized: true - data: - first: - Windows Store Apps: WindowsStoreApps - second: - enabled: 0 - settings: - CPU: AnyCPU - userData: - assetBundleName: - assetBundleVariant: diff --git a/GoogleSignInPlugin/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.h b/GoogleSignInPlugin/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.h index 5e77bc10..d048093f 100644 --- a/GoogleSignInPlugin/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.h +++ b/GoogleSignInPlugin/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.h @@ -15,6 +15,6 @@ */ #import @interface GoogleSignInHandler - : NSObject + : NSObject @end diff --git a/GoogleSignInPlugin/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.mm b/GoogleSignInPlugin/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.mm index 9b82a370..eba6ed10 100644 --- a/GoogleSignInPlugin/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.mm +++ b/GoogleSignInPlugin/Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.mm @@ -105,9 +105,6 @@ - (void)signIn:(GIDSignIn *)signIn case kGIDSignInErrorCodeKeychain: currentResult_->result_code = kStatusCodeInternalError; break; - case kGIDSignInErrorCodeNoSignInHandlersInstalled: - currentResult_->result_code = kStatusCodeDeveloperError; - break; case kGIDSignInErrorCodeHasNoAuthInKeychain: currentResult_->result_code = kStatusCodeError; break; @@ -232,6 +229,10 @@ bool GoogleSignIn_Configure(void *unused, bool useGameSignIn, return result; } +bool GoogleSignIn_CanBeSilent() { + return [GIDSignIn sharedInstance].hasPreviousSignIn; +} + /** * Attempt a silent sign-in. Return value is the pointer to the currentResult * object. @@ -239,7 +240,7 @@ bool GoogleSignIn_Configure(void *unused, bool useGameSignIn, void *GoogleSignIn_SignInSilently() { SignInResult *result = startSignIn(); if (!result) { - [[GIDSignIn sharedInstance] signInSilently]; + [[GIDSignIn sharedInstance] restorePreviousSignIn]; result = currentResult_.get(); } return result; diff --git a/GoogleSignInPlugin/Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm b/GoogleSignInPlugin/Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm index 33631489..3fa88c18 100644 --- a/GoogleSignInPlugin/Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm +++ b/GoogleSignInPlugin/Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm @@ -39,10 +39,10 @@ + (void)load { Method swizzled; original = class_getInstanceMethod( - self, @selector(application:didFinishLaunchingWithOptions:)); + self, @selector(preStartUnity)); swizzled = class_getInstanceMethod( self, - @selector(GoogleSignInAppController:didFinishLaunchingWithOptions:)); + @selector(GoogleSignInAppController_preStartUnity)); method_exchangeImplementations(original, swizzled); original = class_getInstanceMethod( @@ -59,8 +59,7 @@ + (void)load { method_exchangeImplementations(original, swizzled); } -- (BOOL)GoogleSignInAppController:(UIApplication *)application - didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { +- (void)GoogleSignInAppController_preStartUnity { // 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. @@ -75,13 +74,12 @@ - (BOOL)GoogleSignInAppController:(UIApplication *)application // Setup the Sign-In instance. GIDSignIn *signIn = [GIDSignIn sharedInstance]; signIn.clientID = clientId; - signIn.uiDelegate = gsiHandler; signIn.delegate = gsiHandler; + signIn.presentingViewController = UnityGetGLViewController(); // 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]; + [self GoogleSignInAppController_preStartUnity]; } /** @@ -96,10 +94,7 @@ - (BOOL)GoogleSignInAppController:(UIApplication *)application sourceApplication:sourceApplication annotation:annotation]; - return [[GIDSignIn sharedInstance] handleURL:url - sourceApplication:sourceApplication - annotation:annotation] || - handled; + return [[GIDSignIn sharedInstance] handleURL:url] || handled; } /** @@ -112,13 +107,7 @@ - (BOOL)GoogleSignInAppController:(UIApplication *)app BOOL handled = [self GoogleSignInAppController:app openURL:url options:options]; - return [[GIDSignIn sharedInstance] - handleURL:url - sourceApplication: - options[UIApplicationOpenURLOptionsSourceApplicationKey] - annotation: - options[UIApplicationOpenURLOptionsAnnotationKey]] || - handled; + return [[GIDSignIn sharedInstance] handleURL:url] || handled; } @end