Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - push firebase notifications to specific users without firebase auth

I am working with Firebase to push notifications and I don't use Firebase authentication on my app (I have my own system).

I didn't find an answer to this question: Is it possible to push notifications to a specific user with firebase without Firebase authentication (and therefore, without a UID)? How?

like image 720
Thomas Nicole Avatar asked Apr 02 '19 08:04

Thomas Nicole


People also ask

How do you send notifications to specific users with Firebase in Flutter?

To send a notification, go to Firebase Console → Cloud Messaging and click on Send your first message. Then enter the Title and body field. If you wish to send it to a particular device then click on Send test message and enter the FCM registration token.

How do you send notifications to other users on Flutter?

This can simply be done by heading to your Firebase project > Project Settings > Cloud Messaging then copy the API key under Cloud Messaging API (Legacy) . When you have your Firebase Cloud Messaging API key, this is the code to display a notification given the notification title, body, and device token to send it to.


1 Answers

The push notifications are not sent based on user, they are sent based on push notification token that is received when you register for push notifications (iOS & Android).

The push notification token will change in the case of uninstall/install and has nothing to do with what user is logged in in the app, you can send push notifications to apps that don't have users at all.

In order to target a specific user with push notification, you must do something called user segmentation, that is, filter user based on particular properties of these users. In general user segmentation is done by tracking user action and user properties and depends on the push notification platform in use. For example you can track user actions in the app, like user added product to cart, user has x products in cart and then send a push notification to all users that have more than 3 products in cart.

All the push notifications platform link the push notification token to the events triggered.

If you are using firebase, the most easiest way is to track user properties, there are a lot of tutorials on this part. Although, in my opinion, firebase tracking is kind of crappy.

One thing to note, since the push notification token is not linked to the user directly, in case there are two users (two accounts) using the same device they, they will receive push notifications on the same device, so don't send sensitive information via push notifications.

like image 95
danypata Avatar answered Sep 30 '22 01:09

danypata