[OneSignal][Unity] Create ID after login - push-notification

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.

Related

Export Historical user data from Firebase

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.

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?
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.

Enabling the notification feature for my firebase app

I have made an app with the use of firebase. It is basically a chat application in which you van send and receive the text and images. I want to add a functionality in it that whenever a user sends a msg, then another user should get a notification . When I try to send a notification through the firebase console, then it is working, but when a user messages through the app, then it is not showing any notification to another user. So, can anyone tell me that how can this functionality be achieved ?Also, provide some sample code to see how things are working
You need to use cloud functions for that:
https://firebase.google.com/docs/functions
Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests
First, you can register the user to a topic:
FirebaseMessaging.getInstance().subscribeToTopic("news");
https://firebase.google.com/docs/cloud-messaging/android/topic-messaging
Then when the message is sent to the database, you can use onWrite() in cloud functions which is a database trigger to be able to send the notification.
https://firebase.google.com/docs/functions/database-events

How to implement Firebase Invites in my Android application?

I want to implement the Firebase Invite Feature, where a user can send a link which is unique to his/her friends and whenever the other receiver installs the app using this link my application recognize it and act accordingly.
Now I have searched quite a while about Firebase invite and I came to know that you can send the link only via email and android messages. However, I want the user to send via any other social networking app.
What approach should be followed while implementing this?
Firebase Invites is a UI layer to send dynamic links to other users through email. If you want to send the links with another service, you can create them directly using Firebase Dynamic Links.

Gamethrive Onesignal Send push from unit to unit

I am considering switching from pushwoosh to gamethrive / onesignal but am a little confused. I am using the Unity SDK and cant see anywhere in the documentation that I am able to sund push from one unit to a specific othe unit. Can anyone help me clarify if this is possible
Thanks in advance
Yes this is possible.
The OneSignal API supports delivering notifications to individual users or groups of users in several ways. In your case, the best way is probably through the device's OneSignal ID (through the include_player_ids field in the OneSignal API).
You can send notifications from one device to another by interacting through the OneSignal API either on your own backend server or from the code running in your app. However, in either case, you will need to have a backend server to store a list of the OneSignal ID for each one of your users.
Here's a rough outline of the process:
Part A (First getting the OneSignal ID):
A device runs your application for the first time
You initialize OneSignal in your application and you receive a new unique OneSignal ID for this new device in a callback
You then must store this OneSignal ID on your own backend server somewhere.
Part B (Delivering a message):
You wish to send a message to a specific user
You ask your backend server for the OneSignal ID of the user who you wish to send a message to.
You use the OneSignal API to send a message to the user.
Related links:
OneSignal Homepage
OneSignal Documentation Home
OneSignal Notification Delivery API Documentation

Resources