|
1 | 1 | import {type User} from 'common/user' |
2 | 2 | import dayjs from 'dayjs' |
3 | 3 | import utc from 'dayjs/plugin/utc' |
4 | | -import {getAuth, GoogleAuthProvider, OAuthProvider, signInWithCredential, signInWithPopup,} from 'firebase/auth' |
| 4 | +import {getAuth, GoogleAuthProvider, OAuthProvider, signInWithCredential, signInWithPopup, signInWithRedirect} from 'firebase/auth' |
5 | 5 |
|
6 | 6 | import {safeLocalStorage} from '../util/local' |
7 | 7 | import {app} from './init' |
@@ -45,6 +45,16 @@ export function writeReferralInfo( |
45 | 45 | } |
46 | 46 | } |
47 | 47 |
|
| 48 | +export function isAndroidWebView() { |
| 49 | + try { |
| 50 | + // Detect if Android bridge exists |
| 51 | + return typeof (window as any).AndroidBridge?.isNativeApp === 'function'; |
| 52 | + } catch { |
| 53 | + return false; |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | + |
48 | 58 |
|
49 | 59 | export async function googleNativeLogin() { |
50 | 60 | await SocialLogin.initialize({ |
@@ -87,9 +97,10 @@ export async function googleNativeLogin() { |
87 | 97 | export const isRunningInAPK = () => typeof window !== 'undefined' && (window as any).IS_APK === true |
88 | 98 |
|
89 | 99 | export async function firebaseLogin() { |
90 | | - if (isRunningInAPK()) { |
| 100 | + if (isAndroidWebView()) { |
91 | 101 | console.log('Running in APK') |
92 | 102 | return await googleNativeLogin() |
| 103 | + // return await signInWithRedirect(auth, new GoogleAuthProvider()) |
93 | 104 | } |
94 | 105 | console.log('Running in web') |
95 | 106 | const provider = new GoogleAuthProvider() |
|
0 commit comments