Search code examples
functioncloudgeofirestore

Notify nearby users in cloud functions using geofirestore


I have 2 firestore collections - crews/{crew}/clients and crews/{crew}/pros. If a new client registers and a new document is created, I want to search collection pros for pros working the matching sector and living within 5 km (of the new client), and send notification to the pros filtered. In order to implement that in cloud functions, I installed geofirestore using npm, saved crews/{crew}/pros like this; https://i.sstatic.net/YwAFO.png

but after executing this function, I have error message on cloud functions console like this;

Error: Registration token(s) provided to sendToDevice() must be a non-empty string or a non-empty array

Is there anything wrong with my firestore data structure? Thank you.


Solution

  • I found that this data structure was correct, because I could get notification to work with this data structure. I tried another structure like this; https://i.sstatic.net/vtB5X.jpg However, it gave me another error.