I am struggling to find the cause for the duplicate notification message on android using Firebase, Unity and sending from nodejs with the help of node-gcm.
Here is all relative code:
Unity3d client side I got:
public class PushServiceManager : MonoBehaviour
{
public string Identifier;
public string SkuId;
public SQSParameters sqsOptions;
private SQSManager sqs;
// Use this for initialization
void Start()
{
sqs = new SQSManager(this.sqsOptions);
sqs.Initialize(this.gameObject);
Firebase.Messaging.FirebaseMessaging.TokenReceived += OnTokenReceived;
Firebase.Messaging.FirebaseMessaging.MessageReceived += OnMessageReceived;
}
public void OnTokenReceived(object sender, Firebase.Messaging.TokenReceivedEventArgs token)
{
Debug.Log("Received Registration Token: " + token.Token);
RegistrationToken t = new RegistrationToken();
t.id_token = token.Token;
// sends token to node server
sqs.SendRegistrationToken(t);
}
public void OnMessageReceived(object sender, Firebase.Messaging.MessageReceivedEventArgs e)
{
Debug.Log(e.Message.Data.ToString());
}
}
Nodejs server side:
pushNotification(pushRequest, tokens, callback) {
// This is an array of firebase tokens
let registrationTokens = tokens.map(function (token) {
return token.token;
});
let message = new gcm.Message({
timeToLive: pushRequest.ttl
});
let note = {
title: 'Message title',
icon: 'none',
sound: 'none',
body: 'message text'
};
message.addNotification(note);
let payload = {
data: {foo: "foo"}
}
message.addData(payload);
this.sender.send(message, {registrationTokens}, callback);
}
Question:
Why do I get the second empty push notification?
Tapping first one opens up a unity game as expected but tapping that empty one does not.
Where am I going wrong with this?
Thank you!
01.31.17 UPDATE:
Shutout to firebase support team for looking into this issue...