push notifications

Hi!

I am wondering if there is any possibility to add information to the push notifications that gets sent, without showing them to the end user? I would like to know what the push notification is about, and if its a move within a game, the ID of the game that sent it. I see there is a table called “custom” in the event of a notification. Is that something we can use? and if so, how do we use it? Because all I can see now is the “user Alert”.

Hi @borgb.

That is the purpose of the custom table.  When you do a submitMove() it should send out the push notification with the custom table already populated that contains the value of what you sent with submitMove.   Likewise, if you are sending from the dashboard, the “Payload” field is expected to be a valid JSON string that will be the custom table.

As for the other cloud multiplayer API calls, unless there is a parameter for custom data, then I doubt you will have any control over those.  They may or may not use it.  The fields that take a userAlert parameter is the visible part of the message.

Thanks for the answere Rob! Could you also give me an example of how to do this with a submitMove? all I see from the guide is the alert message so not sure how to populate this custom table?

from the multiplayer guide:

[lua]

local params = {
moveContent = “the move data”,
userAlert = “alert message”
}

match:submitMove( params )

[/lua]

moveContent becomes the custom table.

so the content that I set as moveContent should show up as the custom table? I have a listener/function for notifications something like this:

[lua]

function pushNotification( event )

  

end

Runtime:addEventListener( “notification”, pushNotification )

[/lua]

but the custom table that gets returned here is empty. The alert message is correct. Know what can be wrong?

printout of the event:

{“badge”:2,“type”:“remote”,“name”:“notification”,“custom”:[],“sound”:“true”,“alert”:“borgb made his move”,“applicationState”:“active”}

Any news on this? Just need to know how its supposed to work so if anyone has any examples of how they do it and it works for them it would be great!

I have tried looking through the other push notification examples and tutorials, but they dont really show me anything that can point me to what could be wrong here. So can I please get some confirmation that the event.custom is supposed to work? And how is the code supposed to look? because no matter what I try the custom part still comes back empty.

Hi @borgb.

That is the purpose of the custom table.  When you do a submitMove() it should send out the push notification with the custom table already populated that contains the value of what you sent with submitMove.   Likewise, if you are sending from the dashboard, the “Payload” field is expected to be a valid JSON string that will be the custom table.

As for the other cloud multiplayer API calls, unless there is a parameter for custom data, then I doubt you will have any control over those.  They may or may not use it.  The fields that take a userAlert parameter is the visible part of the message.

Thanks for the answere Rob! Could you also give me an example of how to do this with a submitMove? all I see from the guide is the alert message so not sure how to populate this custom table?

from the multiplayer guide:

[lua]

local params = {
moveContent = “the move data”,
userAlert = “alert message”
}

match:submitMove( params )

[/lua]

moveContent becomes the custom table.

so the content that I set as moveContent should show up as the custom table? I have a listener/function for notifications something like this:

[lua]

function pushNotification( event )

  

end

Runtime:addEventListener( “notification”, pushNotification )

[/lua]

but the custom table that gets returned here is empty. The alert message is correct. Know what can be wrong?

printout of the event:

{“badge”:2,“type”:“remote”,“name”:“notification”,“custom”:[],“sound”:“true”,“alert”:“borgb made his move”,“applicationState”:“active”}

Any news on this? Just need to know how its supposed to work so if anyone has any examples of how they do it and it works for them it would be great!

I have tried looking through the other push notification examples and tutorials, but they dont really show me anything that can point me to what could be wrong here. So can I please get some confirmation that the event.custom is supposed to work? And how is the code supposed to look? because no matter what I try the custom part still comes back empty.