I am not sure but as I am working more on my project with AppWrite, I face many new things which I think not possible with AppWrite. After getting overcooked with AppWrite Messaging, I thought to handle Notifications with my own logic. And to do this I need to store each session FCM token in database. So, let's get started with the database structure I want to use: At First, I have a Single Database named as "Database" Inside that I have two collections named as "Users" and "Tokens". As the name suggest Users collection just stores the authenticated user basic details. No problem with this collection.
In the Tokens collections, I want to document like this "User1", "User2", "User3".... Inside each user I want to create something like key value pair. Like
"Session1" : "token1",
"Session2" : "token2",
"Session3" : "token3",
"Session4" : "token4",
Is it possible to create such scenario in AppWrite? I think No. What's your thought?
It's true AppWrite helps me too in many places, but it also doesn't leave to frustrate me😢 Let's see what its developer says.
Why need muliple session token? Why not have a single doc that updates everytime when a user logs in. Say you have a collection of tokens to send notifications. Every token corresponds to each user. As much as I know the token is connected to the device. I will tell you what is my workflow. If a user logs in or creates acc I call the function to getToken. As token exist. Now i call from a function if a doc in the token collection exist of the user. If yes i just modify it with current one else i just create a new doc with the new token. This token lasts untill the app is deleted from the phone. So say if you want to send a notification to me you can search for the doc that is related to my userid and use the token to send a notification to me.
The limit is if the user can have multiple login at same time in different phone, the token would just be related to the one that was new in login
Yeah thats the problem. I want to send notification to all logged in device
In this case you can keep 3-4 more attribute saying Token1,token2,token3, and 3-4 more datetime attribute to check when these token were created token1time,token2time.... Then if the first is empty, you fill that, then go to second and then 3rd. Say you have 5 logged in devices When he logs in 5th time. You just modify it make the 1st attribute value and continue again. This is a bit complecated but i dont think anyone would have more than 5 login at same time
You could add an array of these tokens but you would have to stringify the array when saving in appwrite and pharse the doc attribute to get the array again
And about saving tokens. Its not related to appwrite but its related to firebase 🫥
Yeah that workaround may work. 5 attribute may work.
Previously I was trying with AppWrite Messaging, but it does nothing beside of cooking me🥵 I got overcooked in handling multiple session🤯
Why do you want to handle with multiple login. Why not just limit to one?
Although it is free to send any amount of notification
There's many scenario where it require to handle multiple session. Two big example will be email app, or whats app
Recommended threads
- How to bypass the rate limit on the back...
Once a month my app has a ton of usage and I always run into the Too many requests 429 error. I am trying to optimize the queues and jobs to manage that, but a...
- [SOLVED] Appwrite Cloud and FRA cloud se...
Can anyone estimate how long this will take to resolve? I am checking status here https://status.appwrite.online/
- How to use Operator.arrayAppend on a rel...
Hi, is it possible to use any operator on a relationship column? I have a One to Many relationship column on a table and I would like to add entries to the colu...