Sign In Register

How can we help you today?

Start a new topic

SocialRankChangedMessage push notification not working

I followed this tutorial and was successfully able to send a push notification to my phone using the test described in the tutorial.

 

I am trying to implement a push notification being sent when someones friend beats their score.

 

In my leaderboard, social notifications are on.

 

For SocialRankChangedMessage.

send via socket, is off

send as push, is on

Suppress Push On Socket Send, is off

 

Android is included in device types

 

I log in on my phone (and also successfully call PushRegistrationRequest) as user1, who has a higher score than user 2

 

Then log in as user 2 on the test harness, and submit a score higher than user 1's highest

 

Everything seems to work and I can see the social scoreboard on my phone with the new score,

but I never get any push notification. What am I missing? thanks!

1 person has this question

Hi Brian


When are you sending the PushRegistrationRequest? 

The push id only needs to be sent to gamesparks once, sending it multiply times can effect the push messages and cause them not to work.

Does player 2 have the app open or is it in the background?


Regards

Katie


1 person likes this
I was calling PushRegistrationRequest every time a user logs on. Though it didnt seem to be causing issues with the test push notification, which worked fine every time.

Player 2 does not have the app open, I'm authenticating and submitting a high score for them via the test harness.
Player 1, may or may not have it open, it doesnt seem to make any difference.


Based on ure comment I should add some push device management, so I'm not calling PushRegistrationRequest every time, and so if a new user logs on the old push registration is cancelled and so on.
(Btw I did call PushRegistrationRequest for a few of my test users on my phone, including player 2 I think, so maybe that is causing an issue??)

 

Hi Brian


I would recommend not sharing push ids(devices) along test players as this can complicate testing.

Have you been able to see if the SocialRankChangeMessage is being called via Analytics->APIStream Type->equal-> SocialRankChangeMessage ?


Regards

Katie

I checked the analytics and the the SocialRankChangeMessage is being called
{
  "@class":".SocialRankChangedMessage",
  "gameId":303237,
  "leaderboardName":"High scores leaderboards",
  "leaderboardShortCode":"SCOREBOARD",
  "messageId":"5921860c86972904dfbbc77f",
  "notification":true,
  "playerId":"592179cd900bea04f562d4c8",
  "subTitle":"SUBTITLE",
  "summary":"Your social rank has changed on the High scores leaderboards leaderboard",
  "them":{
    "LEVEL":0,
    "SCORE":50004,
    "_id":"580541f2b5973404cf31b7d4",
    "city":"Longford",
    "country":"IE",
    "dataComplete":true,
    "externalIds":{
      "FB":"120466395089815"
    },
    "loc":[53.733306884765625,-7.8000030517578125],
    "ts":1495369228564,
    "userId":"580541f2b5973404cf31b7d4",
    "userName":"Helen Alacgicfedchj Occhinowitz",
    "v":4,
    "when":"2017-05-21T12:20Z"
  },
  "title":"TITLE",
  "you":{
    "LEVEL":0,
    "SCORE":50003,
    "city":"Longford",
    "country":"IE",
    "externalIds":{
      "FB":"163811674153970"
    },
    "userId":"592179cd900bea04f562d4c8",
    "userName":"James Floop",
    "when":"2017-05-21T12:19Z"
  }
}

 

I did try to do a better test this morning, with a different device and two new users. Just call push registration once for one user and then try it.. But the firebase SDK is not working on my other phone >:(    (an old S2)


Next thing I will try is to unregister all the users from my device and try the above test on that.

btw How do I unregister a device for push notifications?

Thanks a lot!!

 

Hi Brian


It's isn't possible to unregister a device that is connected to a player.

Push notifications will only work when the app is not open.

Can you try sending a push using a custom event and message?


Regards

Katie 

 

So the test push notification from the tutorial works on my phone for multiple users that have registered the device
Thats a custom event with this cloud code.
var msg = Spark.message(null);
msg.setPlayerIds([Spark.getPlayer().getPlayerId()]);
msg.setMessageData({"title":"test title","body":"test body"});
msg.send();
 I did also make a custom message called TESTPUSHMESSAGE



and created a custom event with this cloud code
var msg = Spark.message("TESTPUSHMESSAGE")
msg.setPlayerIds([Spark.getPlayer().getPlayerId()]);
msg.send();

 

This did not work, though I'm only starting with gamesparks and dont know what I'm doing, so I dont even know if that should have worked

 

That image did not work..

 

Hi Brian

 


The custom message is not being sent because the Device Types is set to "ANDROID"

Can you leave this blank or set it to "FCM"


Regards

Katie

Ok I think that was the problem!
Leaving that field blank made my custom message work.

I had also setup the SocialRankChangedMessage that way. After blanking that field on SocialRankChangedMessage. now I am getting push notifications when one player beats anothers high score.

The message just appears as..

${data.title}
${data.body}


But hopefullt I should be able to figure out how to customize it.


Just fyi here is what my SocialRankChangedMessage looks like now



Thanks a lot for your help!

Hey I'm totally fine on this matter now btw. Cheers


Also just fyi this reply / comment feature does not work on firefox

Login to post a comment