title: 30-40 second delay in pushing iOS notifications using AWS SNS
body: <p>We are using AWS SNS and APNS to send notifications to iOS (Swift) from a Ruby on Rails server. The notifications are going through to iOS but taking about 30-40 seconds which is unacceptable for our app. We can send test notifications using the AWS console that go through immediately, so it doesn't look like an iOS error. In the logs, we can see the notification hitting AWS and returning a 200 response. So it looks like the delay is between AWS and iOS. How can we make these notifications go through more quickly?</p>
  
  <pre><code>notification = {
    :aps =&gt; {
      "mutable-content" =&gt; 1,
      :category =&gt; category,
      :sound =&gt; "default",
      :extra =&gt; data
    }
  }
  
  notification[:aps][:alert] = { :title =&gt; title, :body =&gt; body } if title
  
  sns_message = {
    :APNS_SANDBOX =&gt; notification.to_json,
    :APNS         =&gt; notification.to_json
  }
  config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
  sns = AWS::SNS::Client.new(
    :access_key_id     =&gt; config['access_key_id'    ],
    :secret_access_key =&gt; config['secret_access_key'],
    :region            =&gt; config['region'           ]
  )
  sns.publish(
    :target_arn =&gt; self.arn,
    :message =&gt; sns_message.to_json,
    :message_structure =&gt; 'json'
  )
  </code></pre>