在云功能中搜索附近的用户

Search nearby users in cloud functions

我有 2 个 firestore 集合 - users/{user}/clientsusers/{user}/pros。如果有新客户注册并创建了新文档,我想在集合 pros 中搜索在匹配领域工作且居住在(新客户)5 公里以内的专业人士,向过滤的专业人士发送通知,然后重定向他们转到显示新客户详细信息的新页面。为了在云功能中实现这一点, 我安装了 geofirestore 并编写了这样的代码;

exports.sendNotification = functions.firestore
.document("users/{user}/clients/{client}")
.onCreate(async snapshot => {
try {
    const clientfield = snapshot.data().field;
    const clientaddress = snapshot.data().address;
    const clientgeopoint = snapshot.data().g.geopoint;
    
    const geocollection = geofirestore.collection('users/{user}/pros');
    const query = geocollection.near({center: clientgeopoint, radius: 5}).where('sector', '==', clientsector);
    const tokenArray = [];
    query.get().then(querySnapshot => {
        querySnapshot.forEach(doc => {
        let token = doc.data().fcmToken
        tokenArray.push(token);
    }) 
  }).catch ((error) => console.log(error));
    const message = {
    "notification": {
        title: 'blah',
        body: 'blah'
    },
}
return await admin.messaging().sendToDevice(tokenArray, message);
} catch (error) {
    console.log(error)
}
})

通知部分现在有效,但我仍然遇到重定向到显示新客户请求详细信息的页面的问题,以便专业人士在他们单击并打开应用程序时查看。当用户单击通知并打开应用程序时,如何将用户重定向到某个页面?感谢您的帮助。

我发布了一个关于在通知点击时重定向到页面的新问题,并在那里得到了答案。请参考这里 ->