Skip to content

Commit c9ec32a

Browse files
committed
Fix APK discrimination
1 parent 13a3013 commit c9ec32a

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

capacitor.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import type { CapacitorConfig } from '@capacitor/cli';
22

3+
const LOCAL_ANDROID = process.env.NEXT_PUBLIC_LOCAL_ANDROID !== undefined
4+
35
const config: CapacitorConfig = {
46
appId: 'com.compass.app',
57
appName: 'Compass',
68
webDir: 'web/.next',
79
server: {
8-
url: 'https://compassmeet.com',
10+
url: LOCAL_ANDROID ? "http://10.0.2.2:3000" : 'https://compassmeet.com',
911
cleartext: true
1012
},
1113
};

web/lib/firebase/users.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {getAuth, GoogleAuthProvider, OAuthProvider, signInWithCredential, signIn
66
import {safeLocalStorage} from '../util/local'
77
import {app} from './init'
88
import {SocialLogin} from "@capgo/capacitor-social-login";
9-
import {Capacitor} from "@capacitor/core";
109

1110
dayjs.extend(utc)
1211

@@ -79,11 +78,14 @@ export async function googleNativeLogin() {
7978
return userCredential
8079
}
8180

81+
export const isRunningInAPK = () => typeof window !== 'undefined' && (window as any).IS_APK === true
8282

8383
export async function firebaseLogin() {
84-
if (Capacitor.isNativePlatform()) {
84+
if (isRunningInAPK()) {
85+
console.log('Running in APK')
8586
return await googleNativeLogin()
8687
}
88+
console.log('Running in web')
8789
const provider = new GoogleAuthProvider()
8890
return signInWithPopup(auth, provider).then(async (result) => {
8991
return result

0 commit comments

Comments
 (0)