using parse with android: the example of app
TRANSCRIPT
Playing with parse.comBuilding an app called Qoffee
Andrea De Gaetano
My Blog: http://pestohacks.blogspot.com
Twitter: @dega1999
the app: www.qoffee.it
Interests: #mobile #security #linux #robots #drones #parkour #ara
What is Parse?Backend as a service
Bought in 2013 by Facebook
SDK for all the major client platforms: android, ios, windows, unity3d, php, iot… blablabla!
Useful to build multi-platform apps
Simplify APP development
“””Free”””(*)
What is Qoffee?My side project
An app that helps people to
find the best coffee in town
keep track of Coffee consumption
With Achievements
Test Parse.com is one of the reason behind this app
The app is available on Play Store and Amazon App Store
https://play.google.com/store/apps/details?id=com.andrea.degaetano.coffelover
What we will see:
Platform Tools Overview
Getting started on Android
Build a Multiple-Login screen
Fetch Cloud Data from your Android App
Build API with Cloud Code
Schedule Tasks
Testo
Platform Tools
Android: Getting Started
Create an account
Create an App on parse.com
Get App keys (in settings)
Download the template APP
Import the project in Android Studio
You need to create Facebook and Twitter App to use “social” login
Template: https://github.com/ParsePlatform/ParseUI-Android
Social-Login ScreenSpecify the following in res/values/strings.xml of each sample project:
parse_app_id and parse_client_key
facebook_app_id
twitter_consumer_key and twitter_consumer_secret
!
Your users will be recorded in a “User” table on Cloud Data
New User creation is already implemented
Email password recovery is already implemented (customizable)
Login Screenshots
https://github.com/ParsePlatform/ParseUI-Android
Connect with Parse Cloud
ParseObject is the class representing a single row in a table in the cloud:
!
!
!
You can pass any supported cloud data type: number, binary files, coordinates, string…
You can view the created data on your parse page
Connect with Parse CloudParseQuery is the class to retrieve data from the cloud:
You can add constraint with where clause to ParseQuery like: • whereGreaterThan(String key, Object value) • whereExists(String key) • whereStartsWith(String key, String prefix) • whereWithinKilometers(String k, ParseGeoPoint p, double maxDistance) • whereEqualTo(String key, Object value)
ListView —> ParseQueryAdapter
To display a list of objects you can: build your own adapter and use ParseQuery use the ParseQueryAdapter
ParseQueryAdapter paginate results by default You can customize the layout
Cloud CodeAll the advantages of the service side code:
expose API
simplify multiplatform support
change app behavior anytime
validate pre and post data creation:
BeforeSave(object): 3 secs timeout
AfterSave (object): 3 secs timeout
The language is Javascript: based on backbone.js
Function should finish in 15 seconds.
Cloud Code: function example
Cloud Code: beforesave example
Cloud CodeParseQuery typical function used:
first: retrieve the first object of a query
each: call a callback for each found record
find: list of objects that satisfies the query
…
Query are limited to a max of 1000 results (default is 100)
More requests you do —> More money you need!
Cloud CodeYou use a terminal tool to upload new code: parse deploy
You can chain multiple operations with Promise
Hard to debug -> upload code, run and watch the results on the log
At least there’s a static analyzer checker
!
You can add external javascript library to your project:
underscore.js
sax.js
xmlreader.js
never work out of the box! :D
Cloud Code: tool
Schedule TaskThe code is similar to cloud code, except for the functions declaration
Necessary for long running task
The job functions require to return status.success o status.error
You need to register the task with the platform
Debug —> Log
Schedule Task: configuration
Schedule Task: rss parsing example
Thanks you!
Andrea De Gaetano
My Blog: http://pestohacks.blogspot.com
Twitter: @dega1999
the app: www.qoffee.it
Interests: #mobile #security #linux #robots #drones #parkour #ara