dados perfil aluno
This commit is contained in:
31
lib/supabase.ts
Normal file
31
lib/supabase.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
import { AppState, Platform } from 'react-native';
|
||||
import 'react-native-url-polyfill/auto';
|
||||
|
||||
// Substitui pelas tuas credenciais se necessário (estas são as que enviaste)
|
||||
const supabaseUrl = 'https://ssorfpctjeujolmtkfib.supabase.co';
|
||||
const supabaseAnonKey = 'sb_publishable_SDocGprdYkUKi04FyfVqmA_Ykirp9cK';
|
||||
|
||||
export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
|
||||
auth: {
|
||||
// No React Native usamos o AsyncStorage para persistir o login
|
||||
storage: AsyncStorage,
|
||||
autoRefreshToken: true,
|
||||
persistSession: true,
|
||||
detectSessionInUrl: false,
|
||||
// Nota: Removido o 'lock' e o 'lockAcquireTimeout' para evitar erros de TS
|
||||
// O Supabase v2 no mobile já gere o fluxo de tokens de forma mais estável sem eles.
|
||||
},
|
||||
});
|
||||
|
||||
// Garante que o refresh do token só acontece quando a app está visível (Foreground)
|
||||
if (Platform.OS !== "web") {
|
||||
AppState.addEventListener('change', (state) => {
|
||||
if (state === 'active') {
|
||||
supabase.auth.startAutoRefresh();
|
||||
} else {
|
||||
supabase.auth.stopAutoRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user