how to send data message to user segment From Rest API - firebase

I'm using Advanced REST API to send data message for push notification.
In firebase console i can select user segment
as "Version","language",Country" etc..But how to select user segment for
Data message sent from REST API?
Or is their any other way to use select User segment for data message?
Also i want to send the notification for the user who has not opened app for few days.Is it possible with firebase data message?

When using the FCM rest API to send message, you can't target Analytics user segments. You can only send to devices identified by their unique token, or to topics where the client app is subscribed. The only way to send a message to a user segment is through the Firebase console.

Related

How to check the successfully received rate of firebase cloud message notification?

I am using firebase api call to send the notification to the users and I want to check how many users got the notifications. I read the documentation of firebase but was unable find how to check send rate, if there is any api call for that. When I send notification to all the users from firebase admin panel after some time firebase start showing send rate and open rate.
I want to know how to get this data if I send the notification through the api call?

How my own backend server can get the device token (FCM) of specific user to send push message?

I have backend service and have to send push message to specific user(IOS device).
So Should the device send token FCM to the service directly after get it from Firebase?
Is it only one way?
Or I can get FCM + customer user name(to know which user sent it to me) from Firebase?
Thank You in advance.

get all notifications sent to a user

I'm using FCM FirebaseMessaging to send push notifications to user of my app.
Is there a way to get all notifications sent to one single user or I have to store them in Firestore db?
It's not entirely clear to me what you mean by "get all notifications sent to one single user". But if you're trying to get a history of all messages previously sent to a user via the FCM API, that's not possible. FCM doesn't remember anything about messages previously sent. You have to keep that record yourself, if that's what you need.

How to get data about Firebase's push notification conversion by it's id

I'm sending data-only-payloaded message to fcm.googleapis.com/fcm/send and receiving it's ID:
{"message_id":6399566057759755347}
After that I can't find this message in my firebase console notifications list but I need to get data about number of receivers and openers of notification and display it on my service (need to get data about conversion by API). Is there the way to implement it? If no - is logging of delivering and opening of notificaions on my own server is a good idea?

Firebase Cloud Messaging to send notification for set of users

I'm developing an app using Firebase, in the app there are groups and for groups there are multiple members. I want to send notifications to members in a particular group based on one of the users activity. As an example in a chat app, notification to others informing there is a new message.
I referred this blog post. As it seems best way to do this is Firebase Topic Messaging, all members can be subscribed to the group id as a topic.
My matter is how to avoid receiving notification to the member who's action causes to the notification.
I tried Firebase message sending to multiple topics but it only allows for two logical operations (&&, ||)
Firebase Cloud Messaging has two types of messages: notification messages and data messages.
The default behavior of Firebase is that notification messages will automatically be displayed if the app is in the background or not running. This behavior cannot be modified. If the app is in the foreground, the notification message will not be automatically shown, it will instead be delivered to your app's code.
Data messages on the other hand will always be delivered to your app's code.
Since the user sending the message will typically have the app open, the default behavior will automatically ensure the notification is not shown on the sending user's device.
But in the blog post you refer to there is a race condition for this. If the user closes the app between the time they send the notification to the server and the time the server sends out the notification, the notification may show on their device too.
If this is a concern for your app, you should not use a notification message. Use a data message instead and include enough information in the message to detect which user has sent it (e.g. the user's uid).

Resources