Class: FwtPushNotificationServer::DeviceTokensController

Inherits:
ApplicationController show all
Defined in:
app/controllers/fwt_push_notification_server/device_tokens_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /device_tokens



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/fwt_push_notification_server/device_tokens_controller.rb', line 28

def create
  @device_token = DeviceToken.find_or_create_by_token(params[:token])
  @device_token.update_attributes({
    :device_id => params[:device_id] || "",
    :device_name => params[:device_name] || ""
  })
  if @device_token.present?
    @device_token.save
    status = 0
  else
    status = -1
  end
  render :json => { :status => status }
end

#indexObject

GET /device_tokens



23
24
25
# File 'app/controllers/fwt_push_notification_server/device_tokens_controller.rb', line 23

def index
  @device_tokens = DeviceToken.page.per(100)
end