using parse with android: the example of app

21
Playing with parse.com Building 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

Upload: dega1999

Post on 28-Jul-2015

348 views

Category:

Mobile


0 download

TRANSCRIPT

Page 1: Using Parse with Android: the example of  app

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

Page 2: Using Parse with Android: the example of  app

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”””(*)

Page 3: Using Parse with Android: the example of  app

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

Page 4: Using Parse with Android: the example of  app

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

Page 5: Using Parse with Android: the example of  app

Testo

Platform Tools

Page 6: Using Parse with Android: the example of  app

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

Page 7: Using Parse with Android: the example of  app

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)

Page 8: Using Parse with Android: the example of  app

Login Screenshots

https://github.com/ParsePlatform/ParseUI-Android

Page 9: Using Parse with Android: the example of  app

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

Page 10: Using Parse with Android: the example of  app

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)

Page 11: Using Parse with Android: the example of  app

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

Page 12: Using Parse with Android: the example of  app

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.

Page 13: Using Parse with Android: the example of  app

Cloud Code: function example

Page 14: Using Parse with Android: the example of  app

Cloud Code: beforesave example

Page 15: Using Parse with Android: the example of  app

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!

Page 16: Using Parse with Android: the example of  app

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

Page 17: Using Parse with Android: the example of  app

Cloud Code: tool

Page 18: Using Parse with Android: the example of  app

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

Page 19: Using Parse with Android: the example of  app

Schedule Task: configuration

Page 20: Using Parse with Android: the example of  app

Schedule Task: rss parsing example

Page 21: Using Parse with Android: the example of  app

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