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?
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.
Related
I have setup a firebase project to track users events and for supporting push notification in my IOS and Android apps. In my apps I was registering for notifications when user completes sign up. However I have a number of users who just opened the app and didn't complete registration. I am planning to send notifications to such users to give them a nudge.
However I don't have the notification tokens for such users in my database. So is there any option to export the details of such users from firebase where I can grab their notification tokens?
I tried using big query and audiences but that wont work with historical data.
It sounds like you're using FCM tokens to send messages. In that case you will always needs an FCM token to send a message to a specific app/device.
FCM doesn't know anything about users of your app; all it knows about are the tokens.
So if you want to send a message to an app instance where the user didn't sign in, you'll need to store the token from the app in your database as soon as the app starts - even before the user signs in. Then when the user signs in, you can associate the token with their UID.
With those steps out of the way, you can query for database for tokens without an associated UID and send them a reminder to complete the registration.
I know there are methods to check both iOS and Android to see if the user has locally disabled push notifications for an app, that is done within the app itself. But if a user disables push notifications for an app is this reported back to FCM? Does FCM know not to send a notification to that user and if so, is there anyway of pulling that info out of FCM.
The reason for this question is if the user hasn't used the app in a while and they disabled push notifications - without the user starting the app (thus getting updated tokens/checking for permissions) there is no way to know the user disabled push notifications - unless we can extract that from FCM.
And along these same lines, if a user has uninstalled the app, does FCM get updated that the token is now invalid due to app removal and removes it from its db - and if so, is there anyway to way to extract this from FCM?
In both cases, we need to either update our DB that the user has disabled push notifications (and possibly use alternate communication methods) or mark the user as 'uninstalled' and thus remove that user from any app communication method (fcm, sms, email).
I am trying out firebase cloud messaging (React-native-firebase) and it seems that I am only able to push notifications to all android/ios users, not specific users. Is there a way to target a specific user. Like if a user invites another user only send notification to that one specific user?
The flow can be this one:
User allow notifications on their device(s)
Grab the generated token and store it in the user document inside a tokens array.
(If the same user connects to your app in another device, add the new token in the tokens array)
If you want to target a specific user, get his UID and send a notification to their devices.
You can also subscribe a user to a topic and send a notification to users subscribed to that topic.
two way:
init
your client-side subscribe the topic.
subscribeToTopic("weather")
your client-side report the user property
setUserProperty("name","TOM");
Firebase Cloud Message Console
crate a notification item like this way
The flow can be this as follows:
User allow notifications on their device(s)
Grab the generated token and store it in the user document inside a tokens array.
(If the same user connects to your app in another device, add the new token in the tokens array)
If you want to target a specific user, get his UID and send a notification to their devices.
You can also subscribe a user to a topic and send a notification to users subscribed to that topic.
I am running into a small issue in my unity app after adding the OneSignal plugin. I can receive push notifications if I send them from the web server and everything is fast. However, my concern is that OneSignal assigns one ID to the device not to the user.
My question is: there is any way to create an ID after my login?
The only problem in the actual state is if the user has multiple accounts or if a friend connects from that device. Both users would have the same ID and therefore both would receive the same notifications.
Thanks.
I would recommend using OneSignal.SendTag in your app to tag the user with your userId when they login. Then when they logout call OneSiganl.DeleteTag to remove it.
This will allow you to send a notification with the tags field on the OneSignal create notification REST API POST call.
I want to create an application which have 2 modes: non-logged-in and logged-in (having username).
I want to send push notifications to devices in both modes. The non-logged-in devices should receive notifications such as general announcements, new events, etc. The logged-in mode devices will also receive same notifications and few more.
Now what I want to do is to subscribe the device to receive notifications for non-logged-in mode then once the user logs in to his account from that device I want to unsubscribe the previous non-logged-in notifications.
I've read the answer to this question : Worklight: Push notification without User ID I think that I can play with onUserSubscribe callback when registering the user and unsubscribe the userId of the persistent cookie.
Is this a good idea ? Is there another suggestion ?
My thinking is that you could register an app to 2 event sources.
The first event source will handle the general notifications that an app should receive, whether a user is logged-in or not.
The second event source will handle the notifications for logged-in users.
When the app launches, subscribe to the first event source.
When the user decides to log-in, subscribe to the second event.
You should allow the user to unsubscribe from both if s/he so chooses, as well.
Additional information:
IBM Worklight 6.1 Information Center: search for "push notifications"
Push Notifications training module
So what you're trying to achieve is push notifications broadcast (send to all users). This is something that you'll be able to do with upcoming Worklight 6.2 release. You will not have to subscribe users according to username, but will be able to specify tags during subscription. And after that you'll be able to send push notifications according to this tags.