Sign In Register

How can we help you today?

Start a new topic

Sending Push Notifications on mobiles

I am using Unity.
I would like to send push notifications on mobiles, but I don't really understand how it works... Is it mandatory to use Firebase? Must I install the SDK? Should I use an SDK for Android and another for iOS?

What is the simplest way to implement Push Notifications using at most only one SDK for both OS? Is it possible?


1 person has this question
1 Comment

 Hi Andrea


For push notifications you need to use a notifications provider(firebase or Apple Push Notification sevice(APNs).

Firebase can be used for both iOS and Android, they have a Unity SDK that is very easy to use.

Once you have the SDK installed you need to add the following code ,the firebase docs go into more detail here,


public void Start() {
  Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
  Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
}

public void OnTokenReceived(object sender, Firebase.Messaging.TokenReceivedEventArgs token) {
  UnityEngine.Debug.Log("Received Registration Token: " + token.Token);
}

public void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e) {
  UnityEngine.Debug.Log("Received a new message from: " + e.Message.From);
}

 

OnTokenRecieved will be fired on first install of the game on device.

The token needs to be saved and sent to Gamesparks using a PushRegistrationRequest

We have a step my step guide to setting up FCM on Gamesparks that you can find here.


Regards

Katie






1 person likes this
Login to post a comment