Skip to content

Commit 893d881

Browse files
author
盧彥辰
committed
feat: 修改GoogleSignIn.mm及GoogleSignInAppController.mm
由原本的@"CLIENT_ID"改為直接寫入.plist內的CLIENT_ID issue #6
1 parent a196538 commit 893d881

File tree

2 files changed

+39
-14
lines changed

2 files changed

+39
-14
lines changed

Assets/Plugins/iOS/GoogleSignIn/GoogleSignIn.mm

+33-12
Original file line numberDiff line numberDiff line change
@@ -223,26 +223,47 @@ bool GoogleSignIn_Configure(void *unused, bool useGameSignIn,
223223
* Sign-In. The return value is a pointer to the currentResult object.
224224
*/
225225
void *GoogleSignIn_SignIn() {
226-
SignInResult *result = startSignIn();
227-
if (!result) {
228-
[[GIDSignIn sharedInstance] signIn];
229-
result = currentResult_.get();
230-
}
231-
return result;
226+
SignInResult *result = startSignIn();
227+
if (!result) {
228+
[[GIDSignIn sharedInstance] setClientID:@"303413321002-osmliudj71vc5e0lqjd8l6mb137v0clj.apps.googleusercontent.com"];
229+
[[GIDSignIn sharedInstance] signIn];
230+
result = currentResult_.get();
231+
}
232+
return result;
232233
}
234+
/*修改前版本*/
235+
//void *GoogleSignIn_SignIn() {
236+
// SignInResult *result = startSignIn();
237+
// if (!result) {
238+
// [[GIDSignIn sharedInstance] signIn];
239+
// result = currentResult_.get();
240+
// }
241+
// return result;
242+
//}
233243

234244
/**
235245
* Attempt a silent sign-in. Return value is the pointer to the currentResult
236246
* object.
237247
*/
238248
void *GoogleSignIn_SignInSilently() {
239-
SignInResult *result = startSignIn();
240-
if (!result) {
241-
[[GIDSignIn sharedInstance] restorePreviousSignIn];
242-
result = currentResult_.get();
243-
}
244-
return result;
249+
SignInResult *result = startSignIn();
250+
if (!result) {
251+
[GIDSignIn sharedInstance].presentingViewController = UnityGetGLViewController();
252+
[[GIDSignIn sharedInstance] setClientID:@"303413321002-osmliudj71vc5e0lqjd8l6mb137v0clj.apps.googleusercontent.com"];
253+
[[GIDSignIn sharedInstance] restorePreviousSignIn];
254+
result = currentResult_.get();
255+
}
256+
return result;
245257
}
258+
/*修改前版本*/
259+
//void *GoogleSignIn_SignInSilently() {
260+
// SignInResult *result = startSignIn();
261+
// if (!result) {
262+
// [[GIDSignIn sharedInstance] restorePreviousSignIn];
263+
// result = currentResult_.get();
264+
// }
265+
// return result;
266+
//}
246267

247268
void GoogleSignIn_Signout() {
248269
GIDSignIn *signIn = [GIDSignIn sharedInstance];

Assets/Plugins/iOS/GoogleSignIn/GoogleSignInAppController.mm

+6-2
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,17 @@ - (BOOL)GoogleSignInAppController:(UIApplication *)application
6868
NSString *path = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info"
6969
ofType:@"plist"];
7070
NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:path];
71-
NSString *clientId = [dict objectForKey:@"CLIENT_ID"];
71+
NSString *clientId = [dict objectForKey:@"303413321002-osmliudj71vc5e0lqjd8l6mb137v0clj.apps.googleusercontent.com"];
72+
/*修改前版本*/
73+
//NSString *clientId = [dict objectForKey:@"CLIENT_ID"];
7274

7375
gsiHandler = [GoogleSignInHandler alloc];
7476

7577
// Setup the Sign-In instance.
7678
GIDSignIn *signIn = [GIDSignIn sharedInstance];
77-
signIn.clientID = clientId;
79+
[[GIDSignIn sharedInstance] setClientID:clientId];
80+
/*修改前版本*/
81+
//signIn.clientID = clientId;
7882
signIn.delegate = gsiHandler;
7983

8084
// looks like it's just calling itself, but the implementations were swapped

0 commit comments

Comments
 (0)