离子电容器一对一聊天通知 [英] Ionic Capacitor One-To-One Chat Notification

查看:78
本文介绍了离子电容器一对一聊天通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是东西:


我已经与离子电容器进行了一对一的私人聊天,并将消息保存在Cloud Firestore中.到目前为止,一切正常.两个用户都可以发送和接收消息.另一方面,我已经根据电容器的官方文档使用FCM(Firebase云消息传递)发出了推送通知( https://capacitorjs.com/docs/guides/push-notifications-firebase ),然后从Firebase的控制台中,我可以在拥有令牌的情况下将通知发布到某些设备.>


那么,当用户收到新消息时,是否也可以使用FCM来实现消息通知?就像whatsapp一样,我们可以与其他普通聊天应用程序进行聊天.

注意:我正在使用离子型电容器 + Angular.不用科尔多瓦.

解决方案

我认为您要做的就是每当获得令牌时,使用user_id或device_id将其保存在数据库中,然后在向收件人发送消息时,您可以从数据库中获取收件人的令牌(例如:获取令牌,其中user_id = recipient_id),然后向该令牌发送通知.

Here's the thing:


I've made an one-to-one private chat with ionic capacitor, saving messages in Cloud Firestore. By far it's working fine. Both users can send and recieve messages. On the other hand, I've made push notification with FCM(Firebase Cloud Messaging) according to official document of capacitor(https://capacitorjs.com/docs/guides/push-notifications-firebase) and from console of Firebase I can publish notificationes to certain device as I've got their tokens.


So, can I implement message notification using FCM as well when a user recieve a new message? Just like whatsapp, wechat o others common chat apps.

Attention: I'm using Ionic Capacitor + Angular. NOT cordova.

解决方案

I think what you have to do is whenever you get the token , save it in your database with the user_id or device_id, then when sending message to a recipient, you get the token of the recipient from database(eg: get token where user_id=recipient_id) then send notification to that token.

这篇关于离子电容器一对一聊天通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆