Skip to content

Commit ecc9ce1

Browse files
shannahcodenameone
authored andcommitted
Changed google plus login to use the ios.gplus.clientId display property for the client id instead of the value returned from GoogleConnect.getClientId so as not to conflict with web oauth settings. This change corresponds to a change on the build server that adds support for the ios.gplus.clientId build hint.
1 parent a9d75c9 commit ecc9ce1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Ports/iOSPort/nativeSources/GoogleConnectImpl.m

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,14 @@ void com_codename1_impl_ios_IOSNative_googleLogin___java_lang_Object(CN1_THREAD_
5555
if (googleLoginCallback == NULL) {
5656
googleLoginCallback = instance;
5757
GPPSignIn *signIn = [GPPSignIn sharedInstance];
58-
signIn.clientID = toNSString(CN1_THREAD_STATE_PASS_ARG get_field_com_codename1_social_GoogleConnect_clientId(googleLoginCallback));
58+
JAVA_OBJECT d = com_codename1_ui_Display_getInstance__(CN1_THREAD_GET_STATE_PASS_SINGLE_ARG);
59+
JAVA_OBJECT jClientID = virtual_com_codename1_ui_Display_getProperty___java_lang_String_java_lang_String_R_java_lang_String(CN1_THREAD_STATE_PASS_ARG d, fromNSString(CN1_THREAD_STATE_PASS_ARG @"ios.gplus.clientId"), JAVA_NULL);
60+
if (jClientID == JAVA_NULL) {
61+
googleLoginCallback = NULL;
62+
NSLog(@"Could not login to Google Plus because 'ios.gplus.clientId' property is not set. Ensure that the ios.gplus.clientId build hint is set");
63+
return;
64+
}
65+
signIn.clientID = toNSString(CN1_THREAD_STATE_PASS_ARG jClientID);
5966
NSString *scope = toNSString(CN1_THREAD_STATE_PASS_ARG get_field_com_codename1_social_GoogleConnect_scope(googleLoginCallback));
6067

6168
if (scope != nil) {
@@ -86,6 +93,7 @@ void com_codename1_impl_ios_GoogleConnectImpl_finishedWithAuth(GTMOAuth2Authenti
8693
set_field_com_codename1_social_GoogleImpl_loginMessage(CN1_THREAD_GET_STATE_PASS_ARG JAVA_NULL, googleLoginCallback);
8794
}
8895
set_field_com_codename1_social_GoogleImpl_loginCompleted(CN1_THREAD_GET_STATE_PASS_ARG JAVA_TRUE, googleLoginCallback);
96+
googleLoginCallback = NULL;
8997
}
9098

9199

0 commit comments

Comments
 (0)