Appoxee Unity - Handling Extra Fields

The Appoxee Unity Plugin contains a method which can be called to handle an incoming push notification.The method will get a JSON formatted String which is the push payload, which was persisted by the plugin.

This document will cover the different payloads (iOS & Android) and how to parse them.

Prerequisite : 

Your plugin must be instantiated prior to calling the GetLastPush() method 

The Method : 

Last Push Payload Received - Example
... String pushPayload = appoxeePlugin.GetLastPush(); //Parse the pushPayload String with your chosen JSON Utility class and write you code logic ...

Parsing the Push Payload

In order to parse the JSON-Formatted String to a JSON Object, you will need to use a utility class to do so.

JsonUtility usage

As of Unity3D ver 5.3, the Class JsonUtility is introduced to help parse json object. Please refer to Unity's manual here.

If you are using Unity3D version lower than 5.3 , you may use other JSON parsing open source projects, such as JSONObject or SimpleJSON.

The following JSON-Formatted Strings are the payloads for Adobe Air under Android OS : 

Android Push Notification Payloads
//No Extra Fields , No Sound , Regular Push : { "alert":"Push Message with no extra fields", "push_description":"Push Message with no extra fields", "p":"301226468", "collapse_key":"301226468" } //No Extra Fields , With Sound , Regular Push : { "push_description":"Push Message with no extra fields but with sound", "collapse_key":"301233338", "sound":"appoxeesound.wav", "alert":"Push Message with no extra fields but with sound", "p":"301233338" } //With Extra Fields , With Sound , Regular Push : { "SampleKey2":"SampleValue2", "SampleKey1":"SampleValue1", "push_description":"Push Message with regular extra fields and with sound", "collapse_key":"301249598", "sound":"appoxeesound.wav", "alert":"Push Message with regular extra fields and with sound", "p":"301249598" } //With Website URL , With Sound , Regular Push : { "push_description":"Push Message with URL and with sound", "collapse_key":"301253096", "apx_url":"http:\/\/www.appoxee.com", "sound":"appoxeesound.wav", "alert":"Push Message with URL and with sound", "p":"301253096" } //With AppStoreID , With Sound , Regular Push : { "push_description":"Push Message with AppStoreID and with sound", "collapse_key":"301253096", "apx_aid":"com.facebook.katana", "sound":"appoxeesound.wav", "alert":"Push Message with URL and with sound", "p":"301253096" } //With DeepLink , With Sound , Regular Push : { "push_description":"Push Message with DeepLink and with sound", "collapse_key":"301253096", "apx_dpl":"sample://route/to/target", "sound":"appoxeesound.wav", "alert":"Push Message with URL and with sound", "p":"301253096" }

 

The following JSON-Formatted Strings are the payloads for Adobe Air under iOS : 

iOS Push Notification Payloads
//Push With Sample Extra Payload { "isRich":false, "badge":1, "didLaunchApp":false, "uniqueID":302044226, "extraFields": {"SampleKey1":"SampleVal1", "SampleKey2":"SampleVal2"}, "isTriggerUpdate":false, "alert":"Extra Fields Test", "pushAction": {"actionButtons":[{}], "appoxeeCategory":false }, "isSilent":false } //Push With URL Payload { "isRich":false, "badge":0, "didLaunchApp":false, "uniqueID":302030012, "extraFields": {"apx_url":"http:\/\/www.walla.co.il"}, "isTriggerUpdate":false, "alert":"Web URL", "pushAction": {"actionButtons":[{}],"appoxeeCategory":false} ,"isSilent":false } //Push With AppStoreID Payload { "isRich":false, "badge":0, "didLaunchApp":false, "uniqueID":302034194, "extraFields": {"apx_aid":"12345678"}, "isTriggerUpdate":false, "alert":"App Store ID", "pushAction": {"actionButtons":[{}],"appoxeeCategory":false} ,"isSilent":false }   //Push With DeepLink Payload { "isRich":false, "badge":1, "didLaunchApp":false, "uniqueID":302018762, "extraFields": {"apx_dpl":"myAppScheme:\/\/Go\/To\/Here"}, "isTriggerUpdate":false, "alert":"iOS DPL", "pushAction":{"actionButtons":[{}],"appoxeeCategory":false}, "isSilent":false }