Open Spencer-Mosley opened 2 months ago
when this filed is updated, add the token to their classrooms. Comments should fix themselves for most part or you could go throough all of their class possts to check but might be over kill. make sperate issue for later down line for this
ask chatgpt to exaplin how push notification tokens work in current code. From there, test creating a user from api/script and see if its token works
I'm going to fix this without testing it. To test it, create a brand new account and sign in from 2 differnt devices and see if it works. Might want to just test multiple features at once related to token logic
added this code in login.js to update the token array instead of just replace the single token // Retrieve the existing tokens array from Firestore const userDocSnapshot = await getDoc(userDocRef); let userTokens = userDocSnapshot.data().userTokens || [];
// Add the new token to the array if it doesn't already exist
if (!userTokens.includes(expoPushToken)) {
userTokens.push(expoPushToken);
}
This will probably break the push notification going down stream as current code probably looks at a single token instead of going through or looking at the first value of an array so im going to comment it out for now til i can test
The code above solves the multi device problem. The actual issue can be fixed by having token logic call the user's token array instead of hardcoding their tokens. That is what i need to fix to solve this issue
needs to be done serverside for security reasons
when the user.pushnotification fieild or array is altered, update something or maybe just map the emails to the keys instead of calling the keys directly