When a function is execute from client side with parameters can we listen to those parameters as well in realtime when subscribing?
You mean to know which parameters were sent to thet function?
yes
Mmm, That sounds like something good to have, But, as of now function executions events return Execution
object
https://appwrite.io/docs/models/execution
It seems like it doesn't contains the sent data.
I read the execute object, I wanted to notify drivers when a client books for a ride
Do you know any approach or I have to save in db for this?
Can you elaborate a bit more?
I was like when a customer books for a ride, I have a function that gets nearby drivers like 5 in a list and we can subscribe to docID for location, then I want to notify the nearest driver, if he accepts or rejects I wanted functions and not saving into db as its too coupled up
Any suggestions?
I'm thinking on something
was like if i had way on getting to know what parameter were sent then in realtime I listen that would solve my issue of not saving in db as it's resource intensive and some hacky way of notifying.
So as of now you can notify a driver?
I can't
Like I want the parameter
I mean listening when function is executed in realtime no issue
So to summarize
- Client ask for a ride
- Function will look for 5 near driver
- The nearest one will ask to take the ride
- If disagree will go to the next driver
This is the right flow?
Yes
Okay, You can choose one of two approaches.
Using FCM/APNs
Use another service to push notification.
Pure Appwrite
One way is to do it with database - very small - as this will give you the best realtime option.
You won't need to create to many rows as of Appwrite special Realtime permission module.
All subscriptions are secured by the permissions system offered by Appwrite, meaning a user will only receive updates to resources they have permission to access.
Using Role.any() on read permissions will allow any client to receive updates.
You can let all the drivers to subscribe to a channel for __bidRides __collection databases.[ID].collections.bidRides.documents
,
But in default no-one will have permission to the collection, which means no-one will get notification for a new / updated document.
So when a new ride came to the system you can:
- Create a new document for it inside the __bidRides __ collection.
- Give the nearest driver
read
permission. - Update one attribute of the document.
- If the driver refuse, repeat step 2 and 3
- Remove the nearest driver permission
- Give the next nearest driver
read
permission - Update one attribute of the document.
Then, when one driver took the ride, then you can just delete the document.
Hope it makes sense.
Thank you
Regarding APN is appwrite supporting at that the moment?
No
Appwrite doesn't have - right now, as Wess and Steven said last week maybe on that topic - right now PN of it self. But I think you should be able to send APN using the Swift SDK.
Thanks alot
Recommended threads
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...