title: Format APNS-style JSON message in Python for use with Amazon SNS
body: <p>I'm creating an iOS app, and for our push notifications, we're using Amazon's Simple Notification Service (SNS).</p>
  
  <p>SNS is wonderful, but the documentation is pretty sparse. I'm using <a href="http://docs.pythonboto.org/en/latest/ref/sns.html">boto</a>, Amazon's Python library, and I've figured out how to send plain-text push notifications:</p>
  
  <pre><code>device_arn = 'MY ENDPOINT ARN GOES HERE'
  plain_text_message = 'a plaintext message'
  sns.publish(message=plain_text_message,target_arn=device_arn)
  </code></pre>
  
  <p>However, what's not clear from the documentation is how to create an an Apple Push Notification Service (APNS) message. I need to send a sound and a badge along with the push notification, but can't figure out how to format the JSON for the message.</p>
  
  <p>Here's my best guess so far:</p>
  
  <pre><code>message = {'default':'default message', 'message':{'APNS_SANDBOX':{'aps':{'alert':'inner message','sound':'mySound.caf'}}}}
  messageJSON = json.dumps(message,ensure_ascii=False)
  sns.publish(message=messageJSON,target_arn=device_arn,message_structure='json')
  </code></pre>
  
  <p>When I run this code, though, all I see on the notification is "default message" - which means that Amazon SNS rejected my message's format, and displayed the <code>default</code> instead.</p>
  
  <p><strong>How do I format this JSON correctly?</strong></p>