title: Send iOS pushnotifications in JSON format trough Amazon SNS
body: <p>I'm in the works of migrating my own iOS pushservice into Amazon SNS. Previously I was pushing messages trough our own server which no longer is enough.</p>
  
  <p>The backend is built with PHP and this is some code of how I send a pushnotification with the old solution:</p>
  
  <pre><code>$body = array(
      'alert' =&gt; array('body' =&gt; $id,
                     'action-loc-key' =&gt; 'read this',
                     'loc-key' =&gt; '%@',
                     'loc-args' =&gt; array($message)),
      'badge' =&gt; '0',
      'sound' =&gt; 'default',
      'content-available' =&gt; '1'
      );
  </code></pre>
  
  <p>That is the body of the notification I sent. Now I want to get the same notification to be sent trough SNS, with the AWS PHP SDK <a href="http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.Sns.SnsClient.html#_publish" rel="nofollow">publish-method</a>.</p>
  
  <p>I've figured out that I have to send the pushnotification trough this:</p>
  
  <pre><code>$result = $snsClient-&gt;publish(array(
          'TargetArn' =&gt; $target,
          // Message is required
          'Message' =&gt; $message,
          'MessageStructure' =&gt; 'json'
      ));
  </code></pre>
  
  <p>What would $message be, in the codeexample above? All help is appreciated!</p>
  
  <p>Edit: I've successfully sent the pushnotification trough SNS dashboard with the following JSON. My problem is to reproduce this trough the PHP SDK.</p>
  
  <p>{
   "APNS":"{\"aps\":{\"alert\":{\"body\":\"7500\", \"action-loc-key\":\"read this\", \"loc-key\":\"%@\", \"loc-args\":[\"Message\"]}, \"badge\":\"0\", \"sound\":\"default\", \"content-available\":\"1\"} }"
  }</p>