Sha256: 89c6d32750b069b937179fc89b258e4011af0ea6e497f37fd5f0cfdfbd2e1a11

Contents?: true

Size: 853 Bytes

Versions: 2

Compression:

Stored size: 853 Bytes

Contents

module NotifyUser
  class UrbanAirship < Push

    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

2 entries across 2 versions & 1 rubygems

Version Path
notify_user-0.3.2 app/models/notify_user/urban_airship.rb
notify_user-0.3.1 app/models/notify_user/urban_airship.rb