Back

[SOLVED] Realtime Subscription Null

  • 0
  • Flutter
  • Realtime
safwan
17 Jun, 2023, 09:33

I'm unfortunately out of ideas for now. I sugges you wait for someone else to respond 😅

TL;DR
Title: Realtime Subscription Null - Solution Provided Solution: - Ensure that you are using a separate realtime instance for each subscription. - Subscribe to the realtime data only after you have confirmed authentication. - Check if you are using the correct variable names and syntax in your code. - Double-check that you are subscribing to the correct events and collections. Other suggestions and discussions: - Multiple users reported facing the issue in the user profile realtime, but not in user posts realtime. - The user found a video tutorial helpful in understanding this issue. - The user requested a project link for further assistance. - The person who responded ran out of ideas
shiva
17 Jun, 2023, 10:57

yeah anyways thanks for responding

Maniac_Fighter
17 Jun, 2023, 11:02

can you please share your project linkg (if possible) please?

Joshima
17 Jun, 2023, 11:04

he followed this videos - https://youtu.be/XnxZLhtkFeg

Joshima
17 Jun, 2023, 11:04

most of the people getting this problem only in user profile realtime not in user posts realtime

Drake
17 Jun, 2023, 15:52

Can you try to make sure to subscribe only after making sure you're authenticated and also use a separate realtime instance for each subscription

shiva
17 Jun, 2023, 18:54

i will try the second suggestion

shiva
17 Jun, 2023, 18:56

and by authentication,you mean to check weather the currentUser==null or not?

Drake
17 Jun, 2023, 19:17

After you call account.get() successfully

shiva
17 Jun, 2023, 19:22

yeah thats done initially for the whole app

Drake
17 Jun, 2023, 19:30

Yes, but just make sure you subscribe after that

shiva
17 Jun, 2023, 19:42

isnt that already ensured when i have a valid session going on or after i have logged in successfully?

Joshima
17 Jun, 2023, 19:46

making different instance ain't working either

Drake
17 Jun, 2023, 20:57

It depends on how your app is set up

shiva
17 Jun, 2023, 21:34

yeah in my app its ensured but the problem is still there .....however i am unable to understand how realtime works at one place flawlessly but on another screen its showing subscription:null message

Drake
17 Jun, 2023, 22:07

And you're using a separate realtime instance? What's your new code?

shiva
18 Jun, 2023, 06:40

we are building the same project and i think he has tried it and its not working

Joshima
18 Jun, 2023, 09:30

In API i used final Realtime _realtimes; whereas I used this - final Realtime _realtime; in user posts and here is my API function accordingly - @override Stream<RealtimeMessage> getLatestUserprofileData() { return _realtimes.subscribe([ 'databases.${AppConstants.APPWRITE_DATABASE_ID}.collections.${AppConstants.APPWRITE_USERS_COLLECIION}.documents' ]).stream; } provider - final getLatestUserProfileDataProvider = StreamProvider((ref) { final userAPI = ref.watch(userAPIProvider); return userAPI.getLatestUserprofileData(); }); UI page - currentUser == null ? const Loader() : SafeArea( child: Scaffold( body: ref.watch(getLatestUserProfileDataProvider).when( data: (data) { if (data.events.contains( 'databases.*.collections.${AppConstants.APPWRITE_USERS_COLLECIION}.documents.${copyOfUser.uid}.update', )) { copyOfUser = UserModel.fromMap(data.payload); } return UserProfile(user: copyOfUser); }, error: (error, st) => ErrorText( error: error.toString(), ), loading: () { return UserProfile(user: copyOfUser); }, ), ), ); here currentUser is a provider for account.get()

Joshima
18 Jun, 2023, 09:56

wait wait it is working now

Joshima
18 Jun, 2023, 09:57

make another provider for it - final apppwriteRealtimeProvider = Provider((ref) { final client = ref.watch(appwriteClientProvider); return Realtime(client); }); - provider for user posts

TypeScript
  final client = ref.watch(appwriteClientProvider);
  return Realtime(client);
});``` - provider for userprofile and don't forget to use this  provider in userApiProvider
Joshima
18 Jun, 2023, 09:58

and then make another instance like i shared above

Joshima
18 Jun, 2023, 09:58

it will start working then

Joshima
18 Jun, 2023, 09:58

thanks @Steven

shiva
20 Jun, 2023, 08:47

thanks @Steven mine also worked🤩

Drake
20 Jun, 2023, 13:13

[SOLVED] Realtime Subscription Null

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more