π Bug Report: Realtime doesn't work on React Native
rohankm opened this issue Β· comments
π Reproduction steps
- create a react native expo app
- init the appwrite
- check the console log
π Expected behavior
As react native does not have window.localstorage, implementing the same with
AsyncStorage from '@react-native-async-storage/async-storage'; would be more sense.
i was checking the docs of supabase. This is how they did it
import AsyncStorage from '@react-native-async-storage/async-storage';
import { createClient } from '@supabase/supabase-js'
const supabaseUrl = YOUR_REACT_NATIVE_SUPABASE_URL
const supabaseAnonKey = YOUR_REACT_NATIVE_SUPABASE_ANON_KEY
export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
localStorage: AsyncStorage as any,
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: false,
});
implementing something like this would be helpful
π Actual Behavior
π² Appwrite version
Version 0.10.x
π» Operating system
MacOS
𧱠Your Environment
No response
π Have you spent some time to check if this issue has been raised before?
- I checked and didn't find similar issue
π’ Have you read the Code of Conduct?
- I have read the Code of Conduct
@rohankm could you please clarify that realtime in react native is what doesn't work?
@stnguyen90 SDK throws the exception below, when trying to subscribe. This is due to that it uses localStorage which is not available in React Native.
TypeError: Cannot read properties of undefined (reading 'getItem')
at WebSocket.onMessage (/xxx/node_modules/appwrite/dist/cjs/sdk.js:181:81)
please assign it to me
@rohankm We now have React Native SDK. Please check it out at https://github.com/appwrite/sdk-for-react-native