OneSignal how to send Push Notification to specific users in ionic2 - android

I am using OneSignal to send notification and I was able to send a notification successfully but now I want to send them to a specific user
or users I know I can create a segment to identify these users but
let say I have a segment for company A and another for company B
how can I add a new user to that segment.
so, in short, this is how the idea in my mind works in my DB I have users that belong to company A and another to company B they open the app and subscribe now how I give them a key to identify them do I send the key from my application or I store it in my DB?

The ability to set data tags is incredibly powerful. You can store data attributes on each user. Tags are available on all OneSignal accounts and are a very popular feature among our customers. Users are tagged with attributes such as types of messages they want to receive, content categories, cart abandonment info, subscription status and user-preferences.
Read more on data tags here.
We have more details in our blog post on data integration with OneSignal

Related

Firebase Cloud Messaging user sending notification to another user

I am designing an application which has two types of user, vendor and Customer. Vendor delivers product and customers order them.
I want to send a notification when a Customer orders something from a vendor. Only that vendor should get notification. Similarly, when the product is mark delivered by vendor, a notification should appear on the customer side.
I was thinking of storing tokens in Firebase Database in the profile for each user, so let's say a customer orders something, he can retrieve Vendor's token so a notification appears on Vendor's side.
I recently came across this answer Cannot resolve symbol com.google.firebase.messaging.Message
which says it's not possible to do so, without admin SDK, which can't be used in Android App.
What options do I have for this use case?
Do I have to create my own server? Is there anyway to do this with just Firebase?
I fell into this same problem before and I solved it by using a token which is the same as in my national number application through the topicKey when the employee sends to the user or I already created the topicKey for the user when he is in the process of registering in the application which is the national number.
When the employee accepts the user’s request, add the order number to the topicKey, which is the national number.
In your problem you can use the phone number because it is a unique code and create a topicKey based on it.
I hope I understood your problem correctly and I apologize for the spelling errors because it is not my native language.

Android: Firebase Cloud Messaging run code before showing notification to filter messages

I'm developing an application for my College:
Users (students) login on it with their college credentials, once they are authenticated, the app creates a Firebase Database data for that user containing al his info, including the disciplines(subjects) that he is on course.
Then comes the Firebase Cloud Messaging part, the users can send notifications for other users that are on the same disciplines.
Example: I'm coursing Math, then can I send a notification to the others users that are also doing Math. There are hundreds of disciplines in my College.
My idea is to send the notification to all of my app's users then, before notifying, handle with some code to check if the user is registered to the notification's target discipline or not, if he is, send notification, else, do not send anything, in others words, filter the message before showing the notification!
I studied several Firebase Cloud Messaging docs and examples but I couldn't find a way how to do it... Can somebody give a light?
Yes, actually, it'd be best to decide server-side on the group of users that will receive the notification, meaning, you need to have them in some sort of group. Firebase has a concept of group and subscription for messaging. And you can setup a cloud function to actually send the message to the clients
https://firebase.google.com/docs/cloud-messaging/js/send-multiple

Sending Firebase Cloud Message using UID of user

I want to build an Android app that allows a user to send notification and data messages to other users. I've started using Firebase only recently, and Firebase Cloud Messaging is still pretty confusing to me.
I have already implemented sending a message to a specific device using the Firebase Instance Id. However, in my app, a user can log out and log into their accounts using different devices, so this isn't really what I want. I read the documentation and it's pretty confusing, they mention sending messages to user groups, and topics (which only apps can subscribe to, not users).
Is there a way to send a push notification directly to another user or a group of users using only their UIDs? If not, is there any other way I can implement this?
I did it storing the FCM Token in a device structure by user. When the user login, add the deviceData to the userToken structure. You need clear deviceData when the user logout. This way, you will only send notifications to logged devices.
Ex (This is not like mine structure, but it can help you to wondering a good way to do this):
-userToken
-idUser1
-device
-idDevice1
-fcmToken: "xxxxx"
-idDevice2
-fcmToken: "YYYYY"
Hope that I helped you
Alright, so to make sure this works across multiple devices when a user logs in, I just make the device subscribe to a topic with the name equal to the user's UID. Now if I want to send a notification to a user, I just send an FCM message on the topic with the name equal to the user's UID!
Example: If my UID is equal to "asdf", whenever I login using multiple devices, each of the devices automatically subscribes to the topic with name "asdf". So now, if I send an FCM from the server on this topic, all the devices from which I am logged on to obtain this notification.

Android Authentication and GCM Push notifications

I'm looking to create for my app some authentication. This will basically consist of a user registering (preferably with their google account, although not necessary) and providing a username that is then sent to my server and then having the ability to log in. I then from there would like to be able for the client app to communicate with my server by sending data and receiving push notifications via GCM (google cloud messaging). It is important that the server is able to send a push notification directly to a certain user not to all registered devices.
Would someone be able to point me in the right direction for what I must do? I've had a look at a few tutorials but what I've seen has always sent messages to all registered devices not to a specific user.
Some extra information about the app:
-The client app (user) will need to send a piece of information to the server. This information will also include the user that it needs to be sent to. Once the server receives the piece of information it should send a push notification through GCM to the specified user's client app.
I'm clueless as to how I need to go about setting up the authentication system, any help would be very appreciated!
Thank you very much,
Daniel
Offcourse you can send push notifications to selected users. This process would roughly comprise the following steps:
1) send the User's GCM registration id to your own server along with a unique user id (what ever id you have assigned to that user; could be email or sim id or something like that). Save it in your database.
2) To send Push notifications to selected users, choose users from the database based on some criteria, retrieve their GCM registration ids from the database and forward them the GCM server.
but there is one important thing you must handle. GCM registration ids could change e.g if user uninstalls and re-installs the application. You must update you corresponding database entry in that case.

Google Cloud Messaging: Can you send to a select group of users?

For a project we need to send push notifications to the user when he/she is expected to fill in some values in our app. I thought about Google Cloud Messaging. However, we will have several locations where the user can be, and only the user in a specific location needs to receive the message.
I see no option in GCM to register with optional variables like "location:6". So, is it possible to group devices/users based on a supplied variable? Or is it only useful for sending notifications to all registered users? If so, are there alternatives?
GCM does allow you to send a push message to a select group of users, but you will need to supply the list of users yourself. This means that if you only want to send a message to a group of users in a certain location, you will need to save these locations on your web server and select the users that meet your criteria.
There is a service called Xtify that lets you send push messages based on location, but I'm pretty sure that's a paid feature.
maintain a db of device registration id(s) , wherein you can have a column containing groupid , and then while querying for the devices to send message to , query based on groupid , you will get device registration id(s) belonging to that group , and then you can send the message to them

Categories

Resources