Back

Account.get() for phoneAuthentication

  • 0
  • Users
  • Flutter
  • Accounts
Binyamin
13 Jun, 2023, 19:15

What error?

TL;DR
User is seeking help in implementing a realtime texting system using Appwrite. They provide some sample code and ask for help understanding the flow. They also inquire about an error they encountered, but do not provide any details about the error. Solution: The support thread does not provide a solution to the user's issue.
Nuaiman
13 Jun, 2023, 19:15

thanks again brother

Nuaiman
13 Jun, 2023, 19:15

I will shwo you

Nuaiman
13 Jun, 2023, 19:16

@override Future<User?> getCurrentAccount() async { try { return await _account.get(); } on AppwriteException catch (e, stackTrace) { return null; } catch (e, stackTrace) { return null; } }

this shoudl be the code

Binyamin
13 Jun, 2023, 19:16
TypeScript
@override
  Future<User?> getCurrentAccount() async {
    try {
      return await _account.get();
    } on AppwriteException catch (e, stackTrace) {
      print(e);
      print(st);
      return null;
    } catch (e, stackTrace) {
      print(e);
      print(st);
      return null;
    }
  }
Nuaiman
13 Jun, 2023, 19:16

but I wrote this ,,,

@override FutureEither<User?> getCurrentAccount() async { try { User? user = await _account.get(); return right(user); } on AppwriteException catch (e, stackTrace) { return left( Failure(e.message ?? 'Some unexpected error occured!', stackTrace)); } catch (e, stackTrace) { return left(Failure(e.toString(), stackTrace)); } }

Nuaiman
13 Jun, 2023, 19:17

how do you do that?

Binyamin
13 Jun, 2023, 19:17

Use three ticks

Binyamin
13 Jun, 2023, 19:17

Then the word dart

Binyamin
13 Jun, 2023, 19:17

Like so

Binyamin
13 Jun, 2023, 19:17
TypeScript
const a = 2;
Nuaiman
13 Jun, 2023, 19:18

let me try

Nuaiman
13 Jun, 2023, 19:18

this is a lien

Nuaiman
13 Jun, 2023, 19:18

aah thanks

Binyamin
13 Jun, 2023, 19:18

Yes it's cool You can use many languages

Binyamin
13 Jun, 2023, 19:19

As for your use case What are the messages

TypeScript
    } on AppwriteException catch (e, stackTrace) {
      return left(
          Failure(e.message ?? 'Some unexpected error occured!', stackTrace));
    } catch (e, stackTrace) {
      return left(Failure(e.toString(), stackTrace));
    }
Nuaiman
13 Jun, 2023, 21:04

hi

Nuaiman
13 Jun, 2023, 21:04

mine was working already at that time

Nuaiman
13 Jun, 2023, 21:04

there is no error

Nuaiman
14 Jun, 2023, 04:41

Hi, @Binyamin

Nuaiman
14 Jun, 2023, 04:42

I am stuck in a situation where I dont understand what shoudl I do to implement a realtime texting system

Nuaiman
14 Jun, 2023, 04:42

could you help me understand the flow?

Binyamin
14 Jun, 2023, 13:23

Implementing a Realtime texting with Appwrite is pretty easy. this is a rough project plan example.

Collections.

You'll need to few collections

  • Rooms = Id for each room, each room can be assigend to a given Team role.
  • Messages = Messages that have UserID & RoomID

Realtime

You'll need to subscribe to the Message collection, for example, where app is the database ID and messages is the collections ID:

TypeScript
final realtime = Realtime(client);

final subscription = realtime.subscribe(['databases.app.collections.messages.documents']);

subscription.stream.listen((response) {
    if(response.events.contains('databases.app.collections.messages.documents.*.create')) {
      // Parse the Document payload
    }
});

This subscription will create a continuous stream that will send all the new documents, But only those the current user is allow to see.

Then you can just add those message to the view / local DB.

Check these links:

Nuaiman
14 Jun, 2023, 14:28

thankyou

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