Sha256: 8521bf248af3090219959c4e4d75b942b5351ddfdc2e798e9d52cebcdc3e084e

Contents?: true

Size: 853 Bytes

Versions: 6

Compression:

Stored size: 853 Bytes

Contents

module NotifyUser
  class UrbanAirship < Apns

    def push
      space_allowance = PAYLOAD_LIMIT - used_space

      payload = {
        :alias  => notification.target_id,
        :aps    => {
          :alert => notification.mobile_message(space_allowance),
          :badge => notification.count_for_target
        },
        :n_data => {
          '#' => notification.id,
          :t  => notification.created_at.to_time.to_i,
          '?' => notification.type
        }
      }

      payload[:n_data]['!'] = notification.params[:action_id] if notification.params[:action_id]

      response = Urbanairship.push(payload)
      if response.success?
        Rails.logger.info "Push notification sent successfully."
        return true
      else
        Rails.logger.info "Push notification failed."
        return false
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
notify_user-0.1.4 app/models/notify_user/urban_airship.rb
notify_user-0.1.3 app/models/notify_user/urban_airship.rb
notify_user-0.1.2 app/models/notify_user/urban_airship.rb
notify_user-0.1.1 app/models/notify_user/urban_airship.rb
notify_user-0.0.30 app/models/notify_user/urban_airship.rb
notify_user-0.0.29 app/models/notify_user/urban_airship.rb