Ionic Capacitor One-To-One Chat Notification - ionic-framework

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.

Related

I already get fcm key of ever users,How to send notification to another user with firebase cloud messaging?In dart

I have Fcm key
and working when i put fcm trial of cloud messageing in firebase
I tried but only got same device notification,
I am expecting that when I send a message to another user The other user need to get a notification while the app is not opened

How to setup push notification with supabase in flutter?

I had just replaced my app with supabase from firebase in flutter app.
Firebase has firebase_messaging that provide push notification to device token.
Is there any facilities to create function in supabase and send notification to selected user with device token while changing in database.
If yes than please suggest some function else suggest some method to send notification.
Supabase does not provide a mechanism to send push notifications at this point, so you can use FCM or other push notification sending services to send them out to the users.
If you are going with FCM, you can setup your own backend using Firebase cloud functions or other backend service that you prefer to send the notifications from.
Typically, you would want to send push notifications to your users when there is some kind of change in the database, like when there was a new message sent or someone liked a post. You can listen to these events using Supabase database webhooks. With database webhooks, you can send your backend a request whenever you receive certain data change happening in your database.

Can I send fcm notifications to Firebase UserIds instead of device tokens?

I see examples where you have to extract device tokens and store them in a db to be able to send notifications to that device.
I wondered if I could use Firebase user ids to send a select list of users notifications skipping the need for tokens?
No firebase is not support to send notification using userID.
You have to integrate FCM package for getting token if firebase using below link :
https://pub.dev/packages/firebase_messaging
After getting token then only you can use this token and send the notification.
Other way of sending notification is the topic.
For topic i am giving you below link :
https://www.filledstacks.com/post/push-notifications-in-flutter-using-firebase/
No, you can't. You need to implement a custom notification sender from the firebase cloud function to send by user IDs. But you can't ignore the FCM tokens. You must register a valid FCM token of the user's device to trigger per device notification. Check the following guideline:
FCM Push Notifications for Flutter

Endpoint Disabled exception returned from AWS SNS when trying to send Push Notifications with Ionic App

I am using AWS SNS to send push notifications to the mobile app built with ionic. Despite the fact that most of the times sending push notifications works perfectly, in some cases the push notification wasn’t sent and it displayed the same error(exception):
Aws\Sns\Exception\EndpointDisabledException Endpoint is disabled
Is there a way to re enable endpoint to AWS SNS after getting Endpoint disabled exception when trying to use Send Push Notifications with Ionic App?
Any ideas?
Thank you
I think I have found the error and resolved it.
It was because sometimes the tokens where mixed when they were sending to multiple devices logged with the same user account.

Sending push notifications when a user likes your post like Instagram

I'm practicing Swift programming by trying to build Instagram for fun. I am using firebase as my database. I was able to set up the activity page where it shows a user has liked/commented on your post.
Now I am wondering how can I actually send a push notification when that happens? I tried using FirebaseMessaging but all I can really do is send messages from firebase directly.
How do I send a specific user a push notification that someone has liked their post?
You can try using Firebase functions. Here are the basic concepts:
To receive notifications, user must subscribe to a "topic" using subscribeToTopic(String topic)
Whenever a post from that topic is created, you use firebase messaging to send message to that topic
To do that, you need to host a function to firebase. That function listens to new posts being posted at whatever node you are using
Everytime a new post is written to that node, it sends the message
Here is the link to the of an example Firebase Functions Example (the function to be hosted is sendNotificationToLocation).
Check this on how to handle subscribing/unsubscribing and handling message/notification Firebase messaging
First do the all configurations for Firebase Cloud Messaging.
Then get firebase registration token of the user whom you want to send a push notifications to.
follow this link for detailed explanation