From eaf79eaf8ff722ac4674173f55127e5223b53b1a Mon Sep 17 00:00:00 2001 From: 3dtours Date: Sat, 27 Jun 2026 20:29:01 +0700 Subject: [PATCH] fix: call GoogleAuth.initialize only on web to resolve Native OAuth error --- frontend/dist/index.html | 2 +- frontend/src/utils/nativePatch.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/dist/index.html b/frontend/dist/index.html index eeaccfa..0b024a4 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -21,7 +21,7 @@ - + diff --git a/frontend/src/utils/nativePatch.ts b/frontend/src/utils/nativePatch.ts index c57fda6..cf8b426 100644 --- a/frontend/src/utils/nativePatch.ts +++ b/frontend/src/utils/nativePatch.ts @@ -26,18 +26,21 @@ function rewriteUrls(obj: any, backendUrl: string): any { return obj; } -if (Capacitor.isNativePlatform()) { - // Initialize native Google Login client to prevent NullPointerException crashes +if (!Capacitor.isNativePlatform()) { + // Initialize Web/PWA Google Login client try { GoogleAuth.initialize({ clientId: import.meta.env.VITE_GOOGLE_CLIENT_ID || '639044397050-7hair384u6lle941h033trut1s3q47l4.apps.googleusercontent.com', scopes: ['profile', 'email'], grantOfflineAccess: true, }); - console.log('[Native OAuth] GoogleAuth initialized successfully.'); + console.log('[Web OAuth] GoogleAuth initialized successfully.'); } catch (e) { - console.error('[Native OAuth] Failed to initialize GoogleAuth client:', e); + console.error('[Web OAuth] Failed to initialize GoogleAuth client:', e); } +} + +if (Capacitor.isNativePlatform()) { // Request native local notification permission on startup try {