aws-sdk-ruby icon indicating copy to clipboard operation
aws-sdk-ruby copied to clipboard

SNS payload not getting to the phone when publishing to a topic

Open goleador opened this issue 13 years ago • 3 comments

So I am now able to publish to a topic however the payload doesn't get to the phone. Here's the code:

  sns_message = {
      :default => self.subject,
      :aps => {
          :alert => self.subject,
          :sound => 'default'
      }.to_json,

      :payload => {
          :notification_type => 'xyz',
          :workout_id => self.workout_id
      }.to_json
  }


  AWS.sns.client.publish :subject => self.subject,
                         :message => sns_message.to_json,
                         :topic_arn => target_arn,
                         :message_structure => 'json'

On the phone:

-(void)receivedPushNotification:(NSDictionary *)dictionary wasInBackground:(BOOL)wasInBackground{

id payload = [dictionary objectForKey:@"payload"];

The payload is nil but the message arrived.

goleador avatar Sep 12 '13 03:09 goleador

Hi @goleador.

Unless you are reporting a specific issue/bug with the SDK, I would suggest posting on the SNS forums about any questions you have about using the API. The forums are a much better place to get support on using specific services, and they can point you in the right direction if you are passing any invalid values. I would also highly recommend reading the source for the sample application discussed in #336 as well as the SNS documentation to help debug your issue, since they explain how to properly use mobile push.

I will close this issue since the SNS forums/support are the right place for this question, not the Ruby SDK. Feel free to reopen if you believe that there is a bug in the SDK.

lsegal avatar Sep 12 '13 04:09 lsegal

Thanks for your help @lsegal. Hope the forums can be as responsive as you. Unfortunately, if I don't get this issue resolved by tomorrow I'll have to go with a different service like Parse or UrbanAirship. Thanks again.

goleador avatar Sep 12 '13 04:09 goleador

@lsegal I got it to work using the AWS console. I just don't know how to make this work using the SDK.

goleador avatar Sep 12 '13 06:09 goleador