Removed Google Sign in
parent
bc0227971d
commit
8b96507226
@ -1,8 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 707de6ade212a46b1ab4bf4d42325176
|
||||
folderAsset: yes
|
||||
timeCreated: 1508956004
|
||||
licenseType: Free
|
||||
guid: a55ee4efaad27d948ba5f03fc6d7bc80
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
@ -1,8 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eefc3dc8b56e545998952bd59ab36247
|
||||
folderAsset: yes
|
||||
timeCreated: 1508956004
|
||||
licenseType: Free
|
||||
guid: ed9b95dc6ed6d0647ad7f1a8f305385d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a089c79cc334748a5a29c5f219b7cfd4
|
||||
folderAsset: yes
|
||||
timeCreated: 1490807626
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7e77ece57ef34772969fad4915b1a4c
|
||||
folderAsset: yes
|
||||
timeCreated: 1490978071
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 938014c9994164100b26d82840a88fbb
|
||||
labels:
|
||||
- gvh
|
||||
timeCreated: 1507661087
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,27 +0,0 @@
|
||||
Assets/GoogleSignIn/Editor/GoogleSignInDependencies.xml
|
||||
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.aar
|
||||
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.aar.md5
|
||||
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.aar.sha1
|
||||
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.pom
|
||||
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.pom.md5
|
||||
Assets/GoogleSignIn/Editor/m2repository/com/google/signin/google-signin-support/1.0.1/google-signin-support-1.0.1.pom.sha1
|
||||
Assets/GoogleSignIn/Future.cs
|
||||
Assets/GoogleSignIn/GoogleSignIn.cs
|
||||
Assets/GoogleSignIn/GoogleSignInConfiguration.cs
|
||||
Assets/GoogleSignIn/GoogleSignInStatusCode.cs
|
||||
Assets/GoogleSignIn/GoogleSignInUser.cs
|
||||
Assets/GoogleSignIn/Impl/BaseObject.cs
|
||||
Assets/GoogleSignIn/Impl/GoogleSignInImpl.cs
|
||||
Assets/GoogleSignIn/Impl/NativeFuture.cs
|
||||
Assets/GoogleSignIn/Impl/SignInHelperObject.cs
|
||||
Assets/Parse/LICENSE
|
||||
Assets/Parse/Plugins/Unity.Compat.dll
|
||||
Assets/Parse/Plugins/Unity.Tasks.dll
|
||||
Assets/PlayServicesResolver/Editor/Google.IOSResolver_v1.2.54.0.dll
|
||||
Assets/PlayServicesResolver/Editor/Google.JarResolver_v1.2.54.0.dll
|
||||
Assets/PlayServicesResolver/Editor/Google.VersionHandler.dll
|
||||
Assets/PlayServicesResolver/Editor/Google.VersionHandlerImpl_v1.2.54.0.dll
|
||||
Assets/PlayServicesResolver/Editor/play-services-resolver_v1.2.54.0.txt
|
||||
Assets/Plugins/Android/native-googlesignin-release.aar
|
||||
Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.h
|
||||
Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 817a6673340324b8ca85e24466f60953
|
||||
labels:
|
||||
- gvh
|
||||
- gvh_manifest
|
||||
- gvh_version-1.0.1
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ade49ef91c70440a0baeac322ecaa2d7
|
||||
folderAsset: yes
|
||||
timeCreated: 1508956004
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
Binary file not shown.
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34b86fc2e934d482ea5f9d1f5354b0f9
|
||||
folderAsset: yes
|
||||
timeCreated: 1508956004
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3becceb8680148d59e5bb93e5eb5a24
|
||||
folderAsset: yes
|
||||
timeCreated: 1508956004
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,14 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad3b09fb652fb4ff0a68d1966f13160e
|
||||
labels:
|
||||
- gvh
|
||||
timeCreated: 1495747145
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,14 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 138b984208e394be797ce8905a44fd54
|
||||
labels:
|
||||
- gvh
|
||||
timeCreated: 1490814915
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,14 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c3999c0f68f04ae08f04fb3bf2a2050
|
||||
labels:
|
||||
- gvh
|
||||
timeCreated: 1495747213
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8948afce6ec0e984aa137d3f84aba688
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,14 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 077933fcaedac412d9762bf3e0a3be68
|
||||
labels:
|
||||
- gvh
|
||||
timeCreated: 1501271136
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,14 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c56b92217d0144af5907627d1235e0a5
|
||||
labels:
|
||||
- gvh
|
||||
timeCreated: 1495747250
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fbe4f3ec9db4415e849f9bb89e63a92
|
||||
folderAsset: yes
|
||||
timeCreated: 1502761839
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,14 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe250cda690a44cb08f8f7d26c9723b4
|
||||
labels:
|
||||
- gvh
|
||||
timeCreated: 1495748295
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,14 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ae1f008f9f994b9c96c1a14067d7b48
|
||||
labels:
|
||||
- gvh
|
||||
timeCreated: 1502758941
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,14 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f1aae79b1ca4432d9d8ec382c54bf46
|
||||
labels:
|
||||
- gvh
|
||||
timeCreated: 1502759707
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,14 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad98e5b48888e44eb81dd5884d3a1754
|
||||
labels:
|
||||
- gvh
|
||||
timeCreated: 1500486239
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 07c86a3f84f494e589218ed67d10255a
|
||||
folderAsset: yes
|
||||
timeCreated: 1490995894
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
@ -1,328 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#import "GoogleSignIn.h"
|
||||
#import <GoogleSignIn/GIDGoogleUser.h>
|
||||
#import <GoogleSignIn/GIDProfileData.h>
|
||||
#import <GoogleSignIn/GIDSignIn.h>
|
||||
#import <GoogleSignIn/GIDToken.h>
|
||||
#import <GoogleSignIn/GIDSignInResult.h>
|
||||
|
||||
#import <memory>
|
||||
|
||||
// These values are in the Unity plugin code. The iOS specific
|
||||
// codes are mapped to these.
|
||||
static const int kStatusCodeSuccessCached = -1;
|
||||
static const int kStatusCodeSuccess = 0;
|
||||
static const int kStatusCodeApiNotConnected = 1;
|
||||
static const int kStatusCodeCanceled = 2;
|
||||
static const int kStatusCodeInterrupted = 3;
|
||||
static const int kStatusCodeInvalidAccount = 4;
|
||||
static const int kStatusCodeTimeout = 5;
|
||||
static const int kStatusCodeDeveloperError = 6;
|
||||
static const int kStatusCodeInternalError = 7;
|
||||
static const int kStatusCodeNetworkError = 8;
|
||||
static const int kStatusCodeError = 9;
|
||||
|
||||
static NSString *cachedLoginHint = nil;
|
||||
static NSArray<NSString *> *cachedAdditionalScopes = nil;
|
||||
|
||||
/**
|
||||
* Helper method to pause the Unity player. This is done when showing any UI.
|
||||
*/
|
||||
void UnpauseUnityPlayer() {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (UnityIsPaused() > 0) {
|
||||
UnityPause(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// result for pending operation. Access to this should be protected using the
|
||||
// resultLock.
|
||||
struct SignInResult {
|
||||
int result_code;
|
||||
bool finished;
|
||||
GIDGoogleUser *user;
|
||||
NSString *serverAuthCode;
|
||||
};
|
||||
|
||||
std::unique_ptr<SignInResult> currentResult_;
|
||||
|
||||
NSRecursiveLock *resultLock = [NSRecursiveLock alloc];
|
||||
|
||||
/**
|
||||
* These are the external "C" methods that are imported by the Unity C# code.
|
||||
* 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.
|
||||
*/
|
||||
void *GoogleSignIn_Create(void *data) { return NULL; }
|
||||
|
||||
void GoogleSignIn_EnableDebugLogging(void *unused, bool flag) {
|
||||
if (flag) {
|
||||
NSLog(@"GoogleSignIn: No optional logging available on iOS");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the GIDSignIn instance. The first parameter is unused in iOS.
|
||||
* It is here to make the API between Android and iOS uniform.
|
||||
*/
|
||||
bool GoogleSignIn_Configure(void *unused, bool useGameSignIn,
|
||||
const char *webClientId, bool requestAuthCode,
|
||||
bool forceTokenRefresh, bool requestEmail,
|
||||
bool requestIdToken, bool hidePopups,
|
||||
const char **additionalScopes, int scopeCount,
|
||||
const char *accountName) {
|
||||
|
||||
int scopeSize = scopeCount;
|
||||
|
||||
if (scopeSize) {
|
||||
NSMutableArray *tmpary =
|
||||
[[NSMutableArray alloc] initWithCapacity:scopeSize];
|
||||
for (int i = 0; i < scopeCount; i++) {
|
||||
[tmpary addObject:[NSString stringWithUTF8String:additionalScopes[i]]];
|
||||
}
|
||||
|
||||
cachedAdditionalScopes = tmpary;
|
||||
}
|
||||
|
||||
if (accountName) {
|
||||
cachedLoginHint = [NSString stringWithUTF8String:accountName];
|
||||
}
|
||||
|
||||
return !useGameSignIn;
|
||||
}
|
||||
|
||||
/**
|
||||
Starts the sign-in process. Returns and error result if error, null otherwise.
|
||||
*/
|
||||
static SignInResult *startSignIn() {
|
||||
bool busy = false;
|
||||
[resultLock lock];
|
||||
if (!currentResult_ || currentResult_->finished) {
|
||||
currentResult_.reset(new SignInResult());
|
||||
currentResult_->result_code = 0;
|
||||
currentResult_->finished = false;
|
||||
currentResult_->user = nil;
|
||||
currentResult_->serverAuthCode = nil;
|
||||
} else {
|
||||
busy = true;
|
||||
}
|
||||
[resultLock unlock];
|
||||
|
||||
if (busy) {
|
||||
NSLog(@"ERROR: There is already a pending sign-in operation.");
|
||||
// Returned to the caller, should be deleted by calling
|
||||
// GoogleSignIn_DisposeFuture().
|
||||
return new SignInResult{.result_code = kStatusCodeDeveloperError,
|
||||
.finished = true};
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* The sign-in flow has finished and was successful if |error| is |nil|.
|
||||
* Map the errors from the iOS SDK back to the Android values for consistency's
|
||||
* sake in the Unity layer.
|
||||
*/
|
||||
void HandleSignInError(NSError * _Nullable _error) {
|
||||
NSLog(@"didSignInForUser: %@", _error.localizedDescription);
|
||||
if (currentResult_) {
|
||||
switch (_error.code) {
|
||||
case kGIDSignInErrorCodeUnknown:
|
||||
currentResult_->result_code = kStatusCodeError;
|
||||
break;
|
||||
case kGIDSignInErrorCodeKeychain:
|
||||
currentResult_->result_code = kStatusCodeInternalError;
|
||||
break;
|
||||
case kGIDSignInErrorCodeHasNoAuthInKeychain:
|
||||
currentResult_->result_code = kStatusCodeError;
|
||||
break;
|
||||
case kGIDSignInErrorCodeCanceled:
|
||||
currentResult_->result_code = kStatusCodeCanceled;
|
||||
break;
|
||||
default:
|
||||
NSLog(@"Unmapped error code: %ld, returning Error", static_cast<long>(_error.code));
|
||||
currentResult_->result_code = kStatusCodeError;
|
||||
}
|
||||
|
||||
currentResult_->finished = true;
|
||||
UnpauseUnityPlayer();
|
||||
} else {
|
||||
NSLog(@"No currentResult to set status on!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sign-In. The return value is a pointer to the currentResult object.
|
||||
*/
|
||||
void *GoogleSignIn_SignIn() {
|
||||
SignInResult *result = startSignIn();
|
||||
if (!result) {
|
||||
[GIDSignIn.sharedInstance signInWithPresentingViewController:UnityGetGLViewController() hint:cachedLoginHint additionalScopes:cachedAdditionalScopes completion:^(GIDSignInResult * _Nullable _result, NSError * _Nullable _error) {
|
||||
if (_error == nil) {
|
||||
if (currentResult_) {
|
||||
currentResult_->result_code = kStatusCodeSuccess;
|
||||
currentResult_->finished = true;
|
||||
currentResult_->user = _result.user;
|
||||
currentResult_->serverAuthCode = _result.serverAuthCode;
|
||||
} else {
|
||||
NSLog(@"No currentResult to set status on!");
|
||||
}
|
||||
NSLog(@"didSignInForUser: SUCCESS");
|
||||
} else {
|
||||
HandleSignInError(_error);
|
||||
}
|
||||
}];
|
||||
result = currentResult_.get();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt a silent sign-in. Return value is the pointer to the currentResult
|
||||
* object.
|
||||
*/
|
||||
void *GoogleSignIn_SignInSilently() {
|
||||
SignInResult *result = startSignIn();
|
||||
if (!result) {
|
||||
[GIDSignIn.sharedInstance restorePreviousSignInWithCompletion:^(GIDGoogleUser * _Nullable _user, NSError * _Nullable _error) {
|
||||
if (_error == nil) {
|
||||
if (currentResult_) {
|
||||
currentResult_->result_code = kStatusCodeSuccess;
|
||||
currentResult_->finished = true;
|
||||
currentResult_->user = _user;
|
||||
} else {
|
||||
NSLog(@"No currentResult to set status on!");
|
||||
}
|
||||
NSLog(@"didSignInForUser: SUCCESS");
|
||||
} else {
|
||||
HandleSignInError(_error);
|
||||
}
|
||||
}];
|
||||
result = currentResult_.get();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void GoogleSignIn_Signout() {
|
||||
GIDSignIn *signIn = GIDSignIn.sharedInstance;
|
||||
[signIn signOut];
|
||||
}
|
||||
|
||||
void GoogleSignIn_Disconnect() {
|
||||
GIDSignIn *signIn = GIDSignIn.sharedInstance;
|
||||
// Finished disconnecting |user| from the app successfully if |error| is |nil|.
|
||||
[signIn disconnectWithCompletion:^(NSError *_Nullable _error) {
|
||||
if (_error == nil) {
|
||||
NSLog(@"didDisconnectWithUser: SUCCESS");
|
||||
} else {
|
||||
NSLog(@"didDisconnectWithUser: %@", _error);
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
bool GoogleSignIn_Pending(SignInResult *result) {
|
||||
volatile bool ret;
|
||||
[resultLock lock];
|
||||
ret = !result->finished;
|
||||
[resultLock unlock];
|
||||
return ret;
|
||||
}
|
||||
|
||||
SignInResult *GoogleSignIn_Result(SignInResult *result) {
|
||||
if (result && result->finished) {
|
||||
return result;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int GoogleSignIn_Status(SignInResult *result) {
|
||||
if (result) {
|
||||
return result->result_code;
|
||||
}
|
||||
return kStatusCodeDeveloperError;
|
||||
}
|
||||
|
||||
void GoogleSignIn_DisposeFuture(SignInResult *result) {
|
||||
if (result == currentResult_.get()) {
|
||||
currentResult_.reset(nullptr);
|
||||
} else {
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Private helper function to copy NSString to char*. If the destination is
|
||||
* non-null, the contents of src are copied up to len bytes (using strncpy). The
|
||||
* then len is returned. Otherwise returns length of the string to copy + 1.
|
||||
*/
|
||||
static size_t CopyNSString(NSString *src, char *dest, size_t len) {
|
||||
if (dest && src && len) {
|
||||
const char *string = [src UTF8String];
|
||||
strncpy(dest, string, len);
|
||||
return len;
|
||||
}
|
||||
return src ? src.length + 1 : 0;
|
||||
}
|
||||
|
||||
size_t GoogleSignIn_GetServerAuthCode(SignInResult *gresult, char *buf,
|
||||
size_t len) {
|
||||
NSString *val = gresult->serverAuthCode;
|
||||
return CopyNSString(val, buf, len);
|
||||
}
|
||||
|
||||
size_t GoogleSignIn_GetDisplayName(SignInResult *gresult, char *buf,
|
||||
size_t len) {
|
||||
NSString *val = [gresult->user.profile name];
|
||||
return CopyNSString(val, buf, len);
|
||||
}
|
||||
|
||||
size_t GoogleSignIn_GetEmail(SignInResult *gresult, char *buf, size_t len) {
|
||||
NSString *val = [gresult->user.profile email];
|
||||
return CopyNSString(val, buf, len);
|
||||
}
|
||||
|
||||
size_t GoogleSignIn_GetFamilyName(SignInResult *gresult, char *buf, size_t len) {
|
||||
NSString *val = [gresult->user.profile familyName];
|
||||
return CopyNSString(val, buf, len);
|
||||
}
|
||||
|
||||
size_t GoogleSignIn_GetGivenName(SignInResult *gresult, char *buf, size_t len) {
|
||||
NSString *val = [gresult->user.profile givenName];
|
||||
return CopyNSString(val, buf, len);
|
||||
}
|
||||
|
||||
size_t GoogleSignIn_GetIdToken(SignInResult *gresult, char *buf, size_t len) {
|
||||
NSString *val = [gresult->user.idToken tokenString];
|
||||
return CopyNSString(val, buf, len);
|
||||
}
|
||||
|
||||
size_t GoogleSignIn_GetImageUrl(SignInResult *gresult, char *buf, size_t len) {
|
||||
NSURL *url = [gresult->user.profile imageURLWithDimension:128];
|
||||
NSString *val = url ? [url absoluteString] : nullptr;
|
||||
return CopyNSString(val, buf, len);
|
||||
}
|
||||
|
||||
size_t GoogleSignIn_GetUserId(SignInResult *gresult, char *buf, size_t len) {
|
||||
NSString *val = [gresult->user userID];
|
||||
return CopyNSString(val, buf, len);
|
||||
}
|
||||
} // extern "C"
|
@ -1,35 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 521784ee6b2184e0e947a8fd1508afbc
|
||||
labels:
|
||||
- gvh
|
||||
timeCreated: 1510357716
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
data:
|
||||
first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
data:
|
||||
first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
data:
|
||||
first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#import "GoogleSignIn.h"
|
||||
#import <UnityAppController.h>
|
||||
|
||||
// Controller to handle Google SignIn. The AppController methods are swizzled
|
||||
// into the UnityAppController in order to avoid breaking other code that needs
|
||||
// to handle these messages also.
|
||||
@interface UnityAppController (GoogleSignInAppController)
|
||||
// These are the implementations for GSI. The signatures match the
|
||||
// AppController methods.
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
|
||||
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
openURL:(NSURL *)url
|
||||
options:(NSDictionary<NSString *, id> *)options;
|
||||
|
||||
- (BOOL)application:(UIApplication *)application
|
||||
openURL:(NSURL *)url
|
||||
sourceApplication:(NSString *)sourceApplication
|
||||
annotation:(id)annotation;
|
||||
|
||||
@end
|
@ -1,26 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce40e3e7b37a54617a4683dfc0479c71
|
||||
labels:
|
||||
- gvh
|
||||
timeCreated: 1490998272
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
iOS:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,113 +0,0 @@
|
||||
/**
|
||||
* Copyright 2017 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleSignInAppController.h"
|
||||
#import <GoogleSignIn/GoogleSignIn.h>
|
||||
#import <GoogleSignIn/GIDSignIn.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
/*
|
||||
* Create a category to customize the application. When this is loaded the
|
||||
* method for the existing application and GoogleSignIn are swizzled into the
|
||||
* other's class selector. Then we call our "own" msthod which is actually the
|
||||
* original application's implementation. See more info at:
|
||||
* https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/CustomizingExistingClasses/CustomizingExistingClasses.html
|
||||
*/
|
||||
|
||||
@implementation UnityAppController (GoogleSignInController)
|
||||
|
||||
/*
|
||||
Called when the category is loaded. This is where the methods are swizzled
|
||||
out.
|
||||
*/
|
||||
+ (void)load {
|
||||
Method original;
|
||||
Method swizzled;
|
||||
|
||||
original = class_getInstanceMethod(
|
||||
self, @selector(application:didFinishLaunchingWithOptions:));
|
||||
swizzled = class_getInstanceMethod(
|
||||
self,
|
||||
@selector(GoogleSignInAppController:didFinishLaunchingWithOptions:));
|
||||
method_exchangeImplementations(original, swizzled);
|
||||
|
||||
original = class_getInstanceMethod(
|
||||
self, @selector(application:openURL:sourceApplication:annotation:));
|
||||
swizzled = class_getInstanceMethod(
|
||||
self, @selector
|
||||
(GoogleSignInAppController:openURL:sourceApplication:annotation:));
|
||||
method_exchangeImplementations(original, swizzled);
|
||||
|
||||
original =
|
||||
class_getInstanceMethod(self, @selector(application:openURL:options:));
|
||||
swizzled = class_getInstanceMethod(
|
||||
self, @selector(GoogleSignInAppController:openURL:options:));
|
||||
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"];
|
||||
NSString *serverClientID = [dict objectForKey:@"SERVER_CLIENT_ID"];
|
||||
|
||||
// Setup the Sign-In instance.
|
||||
GIDConfiguration *config = [[GIDConfiguration alloc] initWithClientID:clientId serverClientID:serverClientID];
|
||||
[GIDSignIn.sharedInstance setConfiguration:config];
|
||||
|
||||
// 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];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the auth URL
|
||||
*/
|
||||
- (BOOL)GoogleSignInAppController:(UIApplication *)application
|
||||
openURL:(NSURL *)url
|
||||
sourceApplication:(NSString *)sourceApplication
|
||||
annotation:(id)annotation {
|
||||
BOOL handled = [self GoogleSignInAppController:application
|
||||
openURL:url
|
||||
sourceApplication:sourceApplication
|
||||
annotation:annotation];
|
||||
|
||||
return [GIDSignIn.sharedInstance handleURL:url] ||
|
||||
handled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the auth URL.
|
||||
*/
|
||||
- (BOOL)GoogleSignInAppController:(UIApplication *)app
|
||||
openURL:(NSURL *)url
|
||||
options:(NSDictionary *)options {
|
||||
|
||||
BOOL handled =
|
||||
[self GoogleSignInAppController:app openURL:url options:options];
|
||||
|
||||
return [GIDSignIn.sharedInstance handleURL:url] ||
|
||||
handled;
|
||||
}
|
||||
|
||||
@end
|
@ -1,26 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50b2e1c9319e4446e9dbd9b183790472
|
||||
labels:
|
||||
- gvh
|
||||
timeCreated: 1490998272
|
||||
licenseType: Pro
|
||||
PluginImporter:
|
||||
serializedVersion: 1
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
platformData:
|
||||
Any:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
Editor:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
iOS:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue