Is there a way to send with FCM a push notification directly to a specific device? - firebase

I am doing an application in health in Nativescript and using https://github.com/EddyVerbruggen/nativescript-plugin-firebase
where I need to send a specific user a notification to alert him about something.
I have seen that to send to a specific device, the registration token can be used but is there any other way?
PS : when the user log in, I have an internal id that can be used to identify the user.

There is no other way to securely target an individual device. The registration token is the way the FCM identifies the device.
If you would like a non-secure way of delivering the message, you could try to use a uniquely named topic, but be aware that any device attached to your project will be able to listen to every topic if they just know the name.

Related

How to send a push notification from the Firebase console to a specific GCM/FCM device token ID

In Urban Airship, when I am composing a notification, I can target specific users by searching for a Urban Airship channel_id (device ID):
I sent from Urban Airship the push notification that I am showing above, and I received it successfully. Now I want to do the same thing, send a push notification to a specific device, but now using the Firebase console. The problem is that in Firebase, in the step where I need to specify the target, it only allows me to choose User segment or topic. I was expecting to see a third option: Target specific users (for sending notifications to one or many specific GCM/FCM device token IDs. So my alternative is to add a GCM/FCM device token ID to a topic and then send the push notification to that topic, which is something that I have successfully done before. Nonetheless, that would be a workaround and not the way I would prefer to do this. Is it possible to send push notifications to specific users (by defining the target GCM/FCM device token IDs) from the Firebase console? Thank you.
UPDATE 1: See how the Firebase console (https://console.firebase.google.com/) only shows User segment and Topic as the Target:
First Step:
Second Step:
Third Step:
By design, the notification feature in the console is for sending out broadcast-type events. Sending user-specific alerts would be more of a programmatic operation done through the API.
For sending test messages, there is a console tool for this, explained here.
Note that it is possible to send a notification to one device by subscribing a device to any topic and sending the notification to that topic in the console (keep in mind topics are public and you can't prevent users from signing up to them; fine for testing most likely).
Another alternative is to send a message via HTTP or curl. Perhaps the best resource for this is the quickstart/messaging example.

Web Push Notification

I'm having some series of questions about implementing push notifications. The things are,
I am using Angular for my frontend where am sending my subscription value which is of an object type with key keys like endpoint, auth, etc (is this will be same for every device like mobile, or some other browsers).
Does all the data in that subscription object is mandatory? or only endpoint.
If a user is logged in with more than 10 devices, do I need to store subscription values for each device? is it how it works? Or should I store the last logged in device's subscription value? If so then the rest of 9 won't get any notifications.
If you are storing all the loggedin Device's subscription value, then is a user logged in more than one browser will he get the notification in each browser? Is it a standard practice?
Suggestions are welcome, any standard practices will be helpful.
Thanks in advance
subscription object has the same format for every web device/browser
yes, for more, see the documentation
When we want to send a push message to a user with a payload, there are three inputs we need:The payload itself.The auth secret from the PushSubscription.The p256dh key from the PushSubscription.We've seen the auth and p256dh values being retrieved from a PushSubscription but for a quick reminder, given a subscription we'd need these values:
each device has it's own endpoint and auth keys, so if you want to send push to every device user logged in, you need to store all of them
yes, user gets notifications for all browsers, if you call them.( you're making a post request to device's endpoint )

Send Firebase Cloud Messaging notification to users by user property

I'm trying to send out an FCM message to a specific set of users (or really, a single user) based on a specific user property but looking through the FCM HTTP API I can't seem to find a way to do that. I can send to users via topics, registration tokens, and device group notification keys, but I don't have any of that infrastructure set up in the near term. I know this functionality exists as you can send such a message via the UI, but I'm not seeing how to do it in the API documentation as yet.
There is currently no parameter that you could use to specify a user property (or even for user segments) that will serve as a target for the FCM API to send the message to.
As you've already searched, the only targets possible are single/multiple registration tokens (to and registration_ids), topics, conditions, and device groups (notification_key).
The option you're looking for is currently only available when using the Notifications Console.

Send Parse Push Notifications with ASP.net

I have developed an android application with the Parse push notification service and I can send notification from the Parse website.
How can I send push notifications through my own website using ASP.net? Is there any way?
I checked the Parse documentation but i get confused, I would really appreciate it if someone would help me.
Thanks
I ran into similar confusion. I wasn't even sure how to properly setup the user so that I could send a push notification directly to them. Then I found the following post:
Channels and Targeted Push Notifications
Note the last item under the Channels heading:
Most apps might find it useful to have a channel for each user so that
they can send messages to a user across all their devices and have
users follow others in the app.
So, now I know that I should subscribe each user to a channel that uniquely identifies the user (e.g., the 'bobsmith#foo.org' channel).
After I have subscribed the user to their channel, I can call Parse's REST API via my ASP.NET application. See Sending Pushes in the Parse REST API Developers Guide.
For an ASP.NET/C# example of how to submit a push notification check out this answer.

Push notification IOS/Android

I am writing back end for mobile app, we are sending pushes (something like one user add
another to buddies) he should accept it or decline via push notification(it is required), server got some feedback from notification, and do something.
I am familiar with two techniques about pushes, first I push directly on device using token, second is abstraction when user subscribes for channel and I send push notification on this channel. Id in my application is email, and I suggest to update device token in the database each time user login, and send push on it, but how should I identify device OS ?(IOS/Android)
1) How to scale it, if user have multiple devices, and when user will logout, and login from other device ?
May be there is common solutions for this problem.

Resources