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 appIdtableRowValues:[“notification.shown”, “notification.payload.subtitle”, “notification.payload.title”, “action”]…}
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…}
“oneSignal” : {type:”serviceCall”,enabled:true,isDebug:false, // Turn logging on and off.…}