GameSalad & Playfab: OneSignal Part 1

Posted by

First, we will look at the initial integration steps and then briefly some small changes made to the library. At some point, I plan to have a Part 2 where I show you how to send OneSignal notifications from within Playfab (the integration code is already there, but not the Playfab cloud code example). Before starting, I assume you created an OneSignal account (it is free).

To start, navigate to your project and install the one signal plugin.

$ cordova plugin add onesignal-cordova-plugin

At the top of the integration file (latest version attached) add your OneSignal appId:

“oneSignal” : {
tableColumnsValues:[1],
appId:”xxxxxxxx”, //One signal appId
tableRowValues:[“notification.shown”, “notification.payload.subtitle”, “notification.payload.title”, “action”]
}
Now if you have set up everything correctly you should be able to receive notifications.

Clicking on the notification will bring the app to the foreground or open it. If the player was in the app or the app was in the background you will get these values in the Playfab table inside of GameSalad (there are additional instructions to get this to work even if the app was opened by the notification in the OneSignal documentation).

“notification.shown”

“notification.payload.subtitle”

“notification.payload.title”

“action”

You can add additional values by adding values from the event:

{“notification”:{“shown”:true,”payload”:{“rawPayload”:{“aps”:{“alert”:{“subtitle”:”test”,”title”:”test”,”body”:”test”},”mutable-content”:1,”sound”:”default”},”custom”:{“i”:”5484a91f-db0c-4e18-ba5f-dc413fa31d1f”}},”subtitle”:”test”,”title”:”test”,”sound”:”default”,”body”:”test”,”notificationID”:”5484a91f-db0c-4e18-ba5f-dc413fa31d1f”,”actionButtons”:[]},”isAppInFocus”:false,”displayType”:1},”action”:{}}

into the configuration table in the integration file:

tableRowValues:[“notification.shown”, “notification.payload.subtitle”, “notification.payload.title”, “action”]

That is all for OneSignal integration, but I also made some additional changes to the settings table. Not all are currently wired (but it will be in the future). You can turn on and off modules and turn on and off logging.

Let’s say you don’t want to use OneSignal then all you need to do is turn it off at the top of the integration file:

“oneSignal” : {
type:”serviceCall”,
enabled:true, //Turn off OneSignal
}
Or you want to turn off logging off for OneSignal (errors will still log):
“oneSignal” : {
type:”serviceCall”,
enabled:true,
isDebug:false, // Turn logging on and off.
}
Comments and questions are always welcomed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.