5. Ruboto
JRuby on Android
Open Source
USD$0 - Free as a beer
https://github.com/ruboto/ruboto
martes, 4 de junio de 13
6. Mobile HTTP
API with Ruby
Ruby Web Framework
Open Source
USD$0 - Free as a beer
http://rubyonrails.org/
http://www.sinatrarb.com/
martes, 4 de junio de 13
11. module Twitter
class API < Grape::API
version 'v1'
format :json
prefix 'api'
end
end
martes, 4 de junio de 13
12. helpers do
def current_user
@current_user ||= User.authorize!(env)
end
def authenticate!
error!('401 Unauthorized', 401) unless current_user
end
end
martes, 4 de junio de 13
13. resource :statuses do
desc "Return a personal timeline."
get :home_timeline do
authenticate!
current_user.statuses.limit(20)
end
desc "Create a status."
params do
requires :status, type: String, desc: "Your status."
end
post :tweet do
authenticate!
Status.create!({
user: current_user,
text: params[:status]
})
end
end
martes, 4 de junio de 13
19. module Twitter
class API < Grape::API
version 'v1'
format :json
prefix 'api'
formatter :json, Grape::Formatter::Rabl
resource :statuses do
desc "Return a personal timeline."
get :home_timeline , :rabl => "user" do
authenticate!
@statuses = current_user.statuses.limit(20)
end
end
end
end
Grape::Rabl
martes, 4 de junio de 13
26. Devise - Token Authenticable
def authenticated
if warden.authenticated?
@current_user = current_user
return true
elsif params[:auth_token] and @current_user =
User.find_by_authentication_token(params[:auth_token])
return true
else
error!('401 Unauthorized', 401)
end
end
martes, 4 de junio de 13
28. Push Notifications
Allow to send Apple Push
Notifications (iOS)
https://github.com/jpoz/apns
APNS
martes, 4 de junio de 13
29. APNS - Push Notifications
$ openssl pkcs12 -in cert.p12 -out cert.pem -nodes -clcerts
martes, 4 de junio de 13
30. APNS - Push Notifications
APNS.host = 'gateway.push.apple.com'
# gateway.sandbox.push.apple.com is default
APNS.pem = '/path/to/pem/file'
# this is the file you just created
# Dir.pwd+”/cert.pem” if you have the certificate on the root
APNS.port = 2195
# this is also the default. Shouldn't ever have to set this, but
just in case Apple goes crazy, you can.
martes, 4 de junio de 13
31. APNS - Push Notifications
device_token = '123abc456def'
APNS.send_notification(device_token, 'Hello iPhone!' )
APNS.send_notification(device_token, :alert => 'Hello iPhone!',
:badge => 1, :sound => 'default')
martes, 4 de junio de 13
32. APNS - Push Notifications
martes, 4 de junio de 13
33. Push Notifications
Allow to send push
notifications to Android
phones via Google Cloud
Messaging
GCM
https://github.com/spacialdb/gcm
martes, 4 de junio de 13