Skip to content

Push notifications

Setup

First of all you need to add Firebase credentials into Balnacy.

  1. In Firebase console open integration page and manage service account permissions.

    Screenshot

  2. On the Firebase Cloud Messaging API page, click Enable.

    Screenshot

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

    Screenshot

  4. In Firebase console generate private key.

    Screenshot

  5. Get client_email and private_key from generated json.

  6. Add this data on the Balancy platforms page.

    Screenshot

Push notifications section

This section allows you to manage server pushes.

Screenshot

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

  1. Update unity plugin to the last version.
  2. Send Firebase token to our server.
    1. 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 => {});
      }
      
    2. 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 of ContinueWith) to make sure that function is called from the main Unity thread.

Repeatable pushes

You can create a push notification that will be sent at a specified frequency. For example, every 12 hours.

Screenshot