Fix Android APK Issues Phase 2

This commit is contained in:
RoadtripDJ Dev
2026-05-17 23:36:26 +01:00
parent dedf25c51f
commit a0f11f73e8
14 changed files with 776 additions and 143 deletions

48
App.tsx
View File

@@ -1,41 +1,53 @@
import { StatusBar } from 'expo-status-bar';
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import { View, ActivityIndicator } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import AppNavigator from './src/navigation/AppNavigator';
import { AuthProvider } from './src/contexts/AuthContext';
import * as Linking from 'expo-linking';
import * as QueryParams from 'expo-auth-session/build/QueryParams';
import * as WebBrowser from 'expo-web-browser';
import { handleInitialAuthUrl, subscribeToAuthRedirects } from './src/auth/authRedirect';
import { supabase } from './src/services/supabase';
WebBrowser.maybeCompleteAuthSession();
export default function App() {
const [isBootstrapped, setIsBootstrapped] = useState(false);
useEffect(() => {
const catchTokenOnLoad = async () => {
const url = await Linking.getInitialURL();
if (!url) return;
const bootstrapAuth = async () => {
console.log('[App] Bootstrapping auth...');
await handleInitialAuthUrl();
await supabase.auth.getSession();
// Supabase sends tokens after a '#' which Expo might ignore, replace it with '?'
const cleanUrl = url.replace('#', '?');
const { params, errorCode } = QueryParams.getQueryParams(cleanUrl);
const sub = subscribeToAuthRedirects();
if (params?.access_token) {
console.log('🔥 TOKEN APANHADO NO ARRANQUE!');
await supabase.auth.setSession({
access_token: params.access_token,
refresh_token: params.refresh_token || '',
});
}
setIsBootstrapped(true);
console.log('[App] Bootstrapped auth!');
return () => {
sub.remove();
};
};
catchTokenOnLoad();
bootstrapAuth();
}, []);
if (!isBootstrapped) {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#ffffff' }}>
<ActivityIndicator size="large" color="#0000ff" />
</View>
);
}
return (
<SafeAreaProvider>
<AuthProvider>
<NavigationContainer>
<AppNavigator />
</NavigationContainer>
<StatusBar style="auto" hidden={false} />
<StatusBar style="dark" translucent={false} backgroundColor="#ffffff" hidden={false} />
</AuthProvider>
</SafeAreaProvider>
);