Push Notifications¶
Push Notifications are in closed beta test!
Contact Balancy team to request access to the feature for your project.
Setup¶
First of all you need to add Firebase credentials into Balancy.
-
In Firebase console open integration page and manage service account permissions.
-
On the Firebase Cloud Messaging API page, click Enable.
-
Create additional role (or use existing one) with permission cloudmessaging.messages.create. You can check if you already have this role on the analyzer page.
-
In Firebase console generate private key.
-
Get client_email and private_key from generated json.
-
Add this data on the Balancy platforms page.
Push Notifications section¶
This section allows you to manage server-side pushes.
You can schedule the sending of a push notification for a specific time and to a specific segment of players.
Be careful with segment
Choose the player segment wisely to avoid accidentally sending a push notification to a group of players who should not receive it.
Requirements¶
- Update unity plugin to the last version.
- Send Firebase token to our server.
- You can do it in Firebase callback
Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived
:public void OnTokenReceived(object sender, Firebase.Messaging.TokenReceivedEventArgs token) { Balancy.LiveOps.Pushes.RegisterFirebaseToken(token.Token, data => {}); }
-
But sometimes this callback is called before you authorize in Balancy. So you can manually get and send token after the authorization:
Firebase.Messaging.FirebaseMessaging.GetTokenAsync().ContinueWithOnMainThread(res => { Balancy.LiveOps.Pushes.RegisterFirebaseToken(res.Result, data => {}); });
Use ContinueWithOnMainThread
It's important to use
ContinueWithOnMainThread
(instead ofContinueWith
) to make sure that function is called from the main Unity thread.
- You can do it in Firebase callback
Repeatable Push Notifications¶
You can create a push notification that will be sent at a specified frequency. For example, every 2 days.