Appoxee Adobe Air - Handling Extra Fields
The Appoxee Adobe Air Plugin Constructor contains a parameter to a callback function which will be called every time a push notification is being received. The method will get a JSON formatted String which is the push payload.
This document will cover the different payloads (iOS & Android) and how to parse them.
Prerequisite :
This is how you code should look like in your main actionscript class :
//Add this to imports : import com.appoxee.AppoxeeANE; ... //Add this to class : private var _appoxeeANE:AppoxeeANE; //Add the class's constructor : _appoxeeANE = new AppoxeeANE("YOUR_APPOXEE_APP_KEY","YOUR_APPOXEE_SECRET_KEY",handleIncomingPushMessage); ... //Add this method to get notified when push messages arrive to the device private function handleIncomingPushMessage(payload:String):void { trace("Handle Incoming Push Message Called with : "+result); //Parse the JSON-Formatted String into an ActionScript Object //All fields from JSON are accessible by theit property names here var data:Object = JSON.parse(payload); //Rest of your logic }
Parsing the Push Payload
In order to parse the JSON-Formatted String to an ActionScript Object, you will need to use JSON.Parse() method which part of ActionScript, as explained in the following link.
AppStore ID and URL extra fields handling
Be advised :
The Appoxee AppStoreID Extra Field (apx_aid) & The Appoxee URL Extra Field (apx_url) are being handled internally by the plugin.
The Appoxee AppStoreID Extra Field will divert to the relevant App Store : Apple's on iOS , Google's on Android.
The Appoxee URL Extra Field will open the url in the device's Web Browser.
The following JSON-Formatted Strings are the payloads for Adobe Air under Android OS :
//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 :
//Push with No Extra Payload { "aps": { "alert":"Push with No Extra Payload", "badge":1 } } //Push With Sample Extra Payload { "aps": { "alert":"Push With Sample Extra Payload", "badge":1 }, "SampleKey1":"SampleVal1", "SampleKey2":"SampleVal2" } //Push With URL Payload { "aps": { "alert":"Push With URL Payload", "badge":1 }, "apx_url":"http:\/\/www.nba.com" } //Push With AppStoreID Payload { "aps": { "alert":"Push With AppStoreID Payload", "badge":1 }, "apx_aid”:”112346543” } //Push With DeepLink Payload { "aps": { "alert":"Push With DeepLink Payload", "badge":1}, "apx_dpl”:”sampleurl:\/\/route\/to\/target” } }