In this UA dashboard, our team creates PUSH notifications and dispatches them to our iOS App.
Now I want to create a PHP script to automate sending of some PUSH notifications. The PHP script works fine (it is triggered via some condition in our database) - but I can't figure out how to replicate the JSON payload to trigger a a Deep Link Action.
In the App (in the debugger) when a PUSH is received that was sent via the UA Dashboard (and has a deep link associated) I see a payload which looks like (after being converted to a NSDictionary of course).
{
"com.urbanairship.payload" = {
"^d" = "pannaapp://classes";
"_" = "ad8b930e-6053-43f3-92d4-753a0e14917c";
aps = {
alert = "This is a test of Deep Link PUSH to the Classes tab. ";
};
};
"com.urbanairship.user_notification_id" = "com.apple.UNNotificationDefaultActionIdentifier";
}
Here is the JSON payload I am sending now, from my PHP script. Note here I am using the "extra" data element to pass a custom property (which I call "content-id") - that value is detected by my app and translation into the app opening a certain screen. But what I really want is for this JSON to mimic the payload which would be sent from the UA Dashboard if I had triggered the link from there - using a Deep Link, thus resulting in the payload shown (in part) above!
$json_payload = "{ \"audience\": { \”Tag\” : \”PurchasedSubscriptionEnding\” }, \"notification\": { \"ios\": { \"alert\": \"REMINDER: You're close to completing your subscription.\", \"extra\": { \"content-id\": 20002 } } }, \"device_types\": [ \"ios\" ]}";
Where do I put the whole "com.apple.UNNotificationDefaultActionIdentifier" thing - or do I really need that? How do I encode the "com.urbanairship.payload" in the JSON?
Thanks to anyone who can offer any guidance - like maybe a link to a page in the docs which actually shows how to do this using the API?
Jordan.
Comments
3 comments