Skip to content

Commit c272e12

Browse files
feat: integrate Google Social Login and update configurations
- Removed the @capacitor/android dependency from package.json. - Added google-services.json for Firebase configuration in the Android app. - Modified MainActivity to implement Google login handling with the SocialLoginPlugin. - Updated GoogleService-Info.plist for iOS with new API keys and enabled app invite and GCM features. - Enhanced CORS settings in the API to support both HTTP and HTTPS for Android. - Updated Firebase initialization in web to include platform-specific client IDs.
1 parent ba3b158 commit c272e12

6 files changed

Lines changed: 90 additions & 8 deletions

File tree

android/app/google-services.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"project_info": {
3+
"project_number": "670756745871",
4+
"project_id": "botschat-130ff",
5+
"storage_bucket": "botschat-130ff.firebasestorage.app"
6+
},
7+
"client": [
8+
{
9+
"client_info": {
10+
"mobilesdk_app_id": "1:670756745871:android:7199e8f9db1b33786276fa",
11+
"android_client_info": {
12+
"package_name": "app.botschat.console"
13+
}
14+
},
15+
"oauth_client": [
16+
{
17+
"client_id": "670756745871-1anrnjukhhu0a550j86blm771a2k3jou.apps.googleusercontent.com",
18+
"client_type": 3
19+
}
20+
],
21+
"api_key": [
22+
{
23+
"current_key": "AIzaSyDfcbU5yx92E8nN7lk0f1FLf0g30KExLX4"
24+
}
25+
],
26+
"services": {
27+
"appinvite_service": {
28+
"other_platform_oauth_client": [
29+
{
30+
"client_id": "670756745871-1anrnjukhhu0a550j86blm771a2k3jou.apps.googleusercontent.com",
31+
"client_type": 3
32+
},
33+
{
34+
"client_id": "670756745871-ct1k370fk3h5oj3f3gdabqv1nq2b7r54.apps.googleusercontent.com",
35+
"client_type": 2,
36+
"ios_info": {
37+
"bundle_id": "app.botschat.console"
38+
}
39+
}
40+
]
41+
}
42+
}
43+
}
44+
],
45+
"configuration_version": "1"
46+
}
Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,35 @@
11
package app.botschat.console;
22

3+
import ee.forgr.capacitor.social.login.GoogleProvider;
4+
import ee.forgr.capacitor.social.login.SocialLoginPlugin;
5+
import ee.forgr.capacitor.social.login.ModifiedMainActivityForSocialLoginPlugin;
6+
import com.getcapacitor.PluginHandle;
7+
import com.getcapacitor.Plugin;
8+
import android.content.Intent;
9+
import android.util.Log;
310
import com.getcapacitor.BridgeActivity;
411

5-
public class MainActivity extends BridgeActivity {}
12+
public class MainActivity extends BridgeActivity implements ModifiedMainActivityForSocialLoginPlugin {
13+
14+
@Override
15+
public void onActivityResult(int requestCode, int resultCode, Intent data) {
16+
super.onActivityResult(requestCode, resultCode, data);
17+
18+
if (requestCode >= GoogleProvider.REQUEST_AUTHORIZE_GOOGLE_MIN && requestCode < GoogleProvider.REQUEST_AUTHORIZE_GOOGLE_MAX) {
19+
PluginHandle pluginHandle = getBridge().getPlugin("SocialLogin");
20+
if (pluginHandle == null) {
21+
Log.i("Google Activity Result", "SocialLogin login handle is null");
22+
return;
23+
}
24+
Plugin plugin = pluginHandle.getInstance();
25+
if (!(plugin instanceof SocialLoginPlugin)) {
26+
Log.i("Google Activity Result", "SocialLogin plugin instance is not SocialLoginPlugin");
27+
return;
28+
}
29+
((SocialLoginPlugin) plugin).handleGoogleLoginIntent(requestCode, data);
30+
}
31+
}
32+
33+
@Override
34+
public void IHaveModifiedTheMainActivityForTheUseWithSocialLoginPlugin() {}
35+
}

ios/App/App/GoogleService-Info.plist

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>REVERSED_CLIENT_ID</key>
88
<string>com.googleusercontent.apps.670756745871-ct1k370fk3h5oj3f3gdabqv1nq2b7r54</string>
99
<key>API_KEY</key>
10-
<string>AIzaSyA8NdosgijoZoOSTHoRY4XA5WH-58OF3Yk</string>
10+
<string>AIzaSyCDswVPEt7QqqIgt3EExLUe_LvIk-V36fE</string>
1111
<key>GCM_SENDER_ID</key>
1212
<string>670756745871</string>
1313
<key>PLIST_VERSION</key>
@@ -16,15 +16,19 @@
1616
<string>app.botschat.console</string>
1717
<key>PROJECT_ID</key>
1818
<string>botschat-130ff</string>
19+
<key>STORAGE_BUCKET</key>
20+
<string>botschat-130ff.firebasestorage.app</string>
1921
<key>IS_ADS_ENABLED</key>
2022
<false></false>
2123
<key>IS_ANALYTICS_ENABLED</key>
2224
<false></false>
2325
<key>IS_APPINVITE_ENABLED</key>
24-
<false></false>
26+
<true></true>
2527
<key>IS_GCM_ENABLED</key>
26-
<false></false>
28+
<true></true>
2729
<key>IS_SIGNIN_ENABLED</key>
2830
<true></true>
31+
<key>GOOGLE_APP_ID</key>
32+
<string>1:670756745871:ios:3ec81e478c1ca1116276fa</string>
2933
</dict>
30-
</plist>
34+
</plist>

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"@capacitor/app": "^8.0.1",
6767
"@capacitor/core": "^8.1.0",
6868
"@capacitor/haptics": "^8.0.0",
69-
"@capacitor/android": "^8.1.0",
7069
"@capacitor/ios": "^8.1.0",
7170
"@capacitor/keyboard": "^8.0.0",
7271
"@capacitor/splash-screen": "^8.0.1",

packages/api/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ const PRODUCTION_ORIGINS = [
2525
"https://botschat.app",
2626
"https://botschat-api.auxtenwpc.workers.dev",
2727
"capacitor://localhost", // iOS Capacitor app
28-
"http://localhost", // Android Capacitor app
28+
"http://localhost", // Android Capacitor app (http scheme)
29+
"https://localhost", // Android Capacitor app (https scheme)
2930
];
3031

3132
// CORS and security headers — skip for WebSocket upgrade requests

packages/web/src/firebase.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,14 @@ async function ensureNativeGoogleInit(): Promise<void> {
9595

9696
const iosClientId = import.meta.env.VITE_GOOGLE_IOS_CLIENT_ID as string | undefined;
9797
const webClientId = import.meta.env.VITE_GOOGLE_WEB_CLIENT_ID as string | undefined;
98+
const platform = Capacitor.getPlatform();
9899

99-
console.log("[NativeGoogleSignIn] initialize: iOSClientId =", iosClientId?.substring(0, 20) + "...", "webClientId =", webClientId?.substring(0, 20) + "...");
100+
console.log("[NativeGoogleSignIn] initialize: platform =", platform, "iOSClientId =", iosClientId?.substring(0, 20) + "...", "webClientId =", webClientId?.substring(0, 20) + "...");
100101

101102
await withTimeout(
102103
SocialLogin.initialize({
103104
google: {
105+
webClientId: webClientId || undefined,
104106
iOSClientId: iosClientId || undefined,
105107
iOSServerClientId: webClientId || undefined,
106108
},

0 commit comments

Comments
 (0)