Spencer-Mosley / reddit-clone-yt

reddit-clone-yt.vercel.app
1 stars 0 forks source link

fix push notification token logic to allow for automated/bulk users added to a class #12

Open Spencer-Mosley opened 2 months ago

Spencer-Mosley commented 1 month ago

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

Spencer-Mosley commented 1 month 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

Spencer-Mosley commented 1 month ago

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

Spencer-Mosley commented 3 weeks ago

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

Spencer-Mosley commented 3 weeks ago

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);
    }
Spencer-Mosley commented 3 weeks ago

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

Spencer-Mosley commented 3 weeks ago

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

Spencer-Mosley commented 3 weeks ago

needs to be done serverside for security reasons