I am working on porting my own iOS pushservice to Amazon SNS. I used to push messages through our own server, which was no longer enough.
The backend is built with PHP, and this is the code of how I send pushnotification with the old solution:
$body = array(
'alert' => array('body' => $id,
'action-loc-key' => 'read this',
'loc-key' => '%@',
'loc-args' => array($message)),
'badge' => '0',
'sound' => 'default',
'content-available' => '1'
);
This is the body of the notification that I sent. Now I want the same notification to be sent via SNS, with the AWS PHP SDK publish-method .
I realized that I needed to send pushnotification through this:
$result = $snsClient->publish(array(
'TargetArn' => $target,
'Message' => $message,
'MessageStructure' => 'json'
));
What will be the message $ message in the codeexample example above? All help is appreciated!
Edit: I successfully sent the SNN launcher using the following JSON. My problem is to reproduce this through the PHP SDK.
{
"APNS": "{\" aps\ ": {\" alert\ ": {\" body\ ": \" 7500\ ", \" action-loc-key\ ": \" read this\ ",\" loc-key \ ":\" % @\ ",\" loc-args \ ": [\" Message \ "]},\" \ ":\" 0 \ ",\" sound \ ":\" default \ ",\" content-available \ ":\" 1 \ "}}"
}