1

Using these three tools, I'm trying to think of the best way to notify a user when the other user in a chat sends them a message (using APNs).

Would it be reasonable to store (and always update to newest value) the fcm registration token as a field under the user document in firestore, then in cloud functions, create a trigger to respond to new messages being sent (where each message is a document)? Then in order to determine which device to send it to, we use the registration token field?

Is there a better way to do this?

E.SK
  • 121
  • 9
  • 1
    Storing tokens by users (typically identified by their UID) sounds reasonable, although I'd keep in mind that a single user can be signed in on multiple devices, so may have multiple tokens. Do you have specific concerns? – Frank van Puffelen Feb 14 '19 at 06:02
  • Hmmm good point, I hadn't thought of that. I read through this and got no answers: https://stackoverflow.com/questions/44496966/how-to-handle-multiple-firebase-fcm-tokens-per-user I wonder if there is a way to truly get the device ID, then I could store a map of {deviceId: updatedUniqueToken}. UIDevice.current.identifierForVendor?.uuidString seems like a good way to get this in swift. – E.SK Feb 14 '19 at 14:22
  • You can use swift to get the device ID according to this [Stackoverflow post](https://stackoverflow.com/questions/25925481/how-to-get-a-unique-device-id-in-swift). The syntax is also detailed. – Michael Feb 16 '19 at 00:02

0 Answers0