LoginSignup
11
8

More than 5 years have passed since last update.

Amazon SNS で Invalid parameter: JSON must contain an entry for 'default' or 'APNS'.

Posted at

Amazon SNS に MessageStructure: json で、Message に JSON いれると、

Invalid parameter: JSON must contain an entry for 'default' or 'APNS'.

などと言われる。APNS のキーはあるのに。。。

よくドキュメントをみると

サンプル:

{ 
"default": "This is the default message which must be present when publishing a message to a topic. The default message will only be used if a message is not present for 
one of the notification platforms.",     
"APNS": "{\"aps\":{\"alert\": \"Check out these awesome deals!\",\"url\":\"www.amazon.com\"} }",
"GCM":"{\"data\":{\"message\":\"Check out these awesome deals!\",\"url\":\"www.amazon.com\"}}",
"ADM": "{ \"data\": { \"message\": \"Check out these awesome deals!\",\"url\":\"www.amazon.com\" }}" 
}

・・・各キーのvalueがエスケープされてる!\(^o^)/
つまり、

to_json( { APNS => to_json({ aps => { alert => "hoge" } } ) } );

だ!

(^q^)

11
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
8