I am trying to send some custom data with the payload to iOS devices. I use the following code to successfully send pushes to all devices but I need to send some additional data. I couldn't find any documentation for urban airship and everything I tried just gives me errors.
Code:
$contents = array();
$contents['badge'] = "+1";
$contents['alert'] = $message;
$contents['sound'] = "cat.caf";
$notification = array();
$notification['ios'] = $contents;
$platform = array();
array_push($platform, "ios");
$push = array("audience"=>"all", "notification"=>$notification, "device_types"=>$platform);
$json = json_encode($push);
$session = curl_init(PUSHURL);
curl_setopt($session, CURLOPT_USERPWD, APPKEY . ':' . PUSHSECRET);
curl_setopt($session, CURLOPT_POST, True);
curl_setopt($session, CURLOPT_POSTFIELDS, $json);
curl_setopt($session, CURLOPT_HEADER, False);
curl_setopt($session, CURLOPT_RETURNTRANSFER, True);
curl_setopt($session, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'Accept: application/vnd.urbanairship+json; version=3;'));
$content = curl_exec($session);
After some research I came to this. In the 'contents' section of your code add this line:
$contents['extra'] = array("message"=>"another message");
This should enable you to send additional custom data along with your push.