appwrite / sdk-for-react-native

[READ ONLY] Official Appwrite React Native SDK 💙 ⚛︎
https://appwrite.io
BSD 3-Clause "New" or "Revised" License
3.78k stars 21 forks source link

🐛 Bug Report: realtime not working in react native expo #23

Closed bilelBoulhia closed 4 months ago

bilelBoulhia commented 4 months ago

👟 Reproduction steps

create a class for a client using react-native-appwrite sdk

import { Client ,Databases} from 'react-native-appwrite';

const client = new Client();
         client.setEndpoint('https://cloud.appwrite.io/v1')
                  .setProject('project_id')
                  .setplatform('host.exp.exponent') //bundle id
                  .setplatform('localhost')

export default client;
export const db = new Databases(client);

creating a listening function and using it in app


function App() {

    useEffect(() => {

        const unsubscribe = client.subscribe(`databases.${IDs.DatabaseId}.collections.${IDs.collectionId}.documents`, response => {

            console.log(response);

        });
        unsubscribe();
    }, []);

}

👍 Expected behavior

it should console log a response

👎 Actual Behavior

it will only work ( only on the web) if i use this import { Client ,Databases} from 'appwrite'; instead of this import { Client ,Databases} from 'react-native-appwrite'; the error : image_2024-07-18_031948457

🎲 Appwrite version

Version 0.10.x

💻 Operating system

Windows

🧱 Your Environment

No response

👀 Have you spent some time to check if this issue has been raised before?

🏢 Have you read the Code of Conduct?

stnguyen90 commented 4 months ago

Closing as this is being discussed on Discord: https://discord.com/channels/564160730845151244/1263322266066747432