Reputation: 104125
I’m trying to send a push notification using Amazon SNS. This is how I create the message body:
NSDictionary *message = @{
@"APNS_SANDBOX" : @{@"aps" : @{@"alert": @"foo"}},
@"default" : @"bar"
};
NSData *JSONData = [NSJSONSerialization dataWithJSONObject:message options:0 error:NULL];
NSString messageBody = [[NSString alloc] initWithData:JSONData encoding:NSUTF8StringEncoding];
The notification arrives at the destination device, but the message is “bar”, not “foo”. In other words, the default transport is used, not the APNS-specific one. What am I doing wrong?
Upvotes: 0
Views: 328
Reputation: 104125
The catch is that the value for a given transport key is supposed to be an already serialized JSON string:
NSDictionary *message = @{
@"APNS_SANDBOX" : @"{\"aps\":{\"alert\":\"foo\"}}",
@"default" : @"bar"
};
This works fine.
Upvotes: 1