sdk-for-web icon indicating copy to clipboard operation
sdk-for-web copied to clipboard

๐Ÿ› Bug Report: Realtime doesn't work on React Native

Open rohankm opened this issue 2 years ago โ€ข 4 comments

๐Ÿ‘Ÿ Reproduction steps

  1. create a react native expo app
  2. init the appwrite
  3. 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

Screenshot 2022-07-08 at 5 25 10 AM

๐ŸŽฒ 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?

  • [X] I checked and didn't find similar issue

๐Ÿข Have you read the Code of Conduct?

rohankm avatar Jul 07 '22 23:07 rohankm

@rohankm could you please clarify that realtime in react native is what doesn't work?

stnguyen90 avatar Sep 21 '22 17:09 stnguyen90

@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)

solita-jtn avatar Oct 14 '22 08:10 solita-jtn

please assign it to me

prathamesh3707 avatar Oct 03 '23 03:10 prathamesh3707

@rohankm We now have React Native SDK. Please check it out at https://github.com/appwrite/sdk-for-react-native

lohanidamodar avatar Mar 08 '24 04:03 lohanidamodar