Backend as a Service: Parse - Moriconi

45
ROME 11-12 april 2014 ROME 11-12 april 2014 Backend as a Service: Parse [email protected] Maurizio Moriconi

description

Slides from Maurizio Moriconi talk @ codemotion roma 2014

Transcript of Backend as a Service: Parse - Moriconi

Page 1: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014ROME 11-12 april 2014

Backend as a Service: Parse

[email protected]

Maurizio Moriconi

Page 2: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Maurizio Moriconi

2

• CTO @ Mobilesoft

• Mobile Developer

• Co-founder

• Main Developer

http://www.facebook.com/maurizio.moriconi

http://www.linkedin.com/in/bugman

@bugman79

- Maurizio Moriconi

Page 3: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Develop an app Push Notification

Analytics

User management

Social integration

Shared data

Web Hosting

Database hosting

3

Page 4: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Challenges

!

• Time • Skill • Scalability • Cost

4

Page 5: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Backend as a Service (Baas)

• MBaaS (mobile backend as a service) !

• Link application to backend cloud storage • Custom software development kit (SDK) • Custom application programming interfaces (APIs)

!

Global Market • $216.5 million in 2012 • $7.7 billion by 2017

5

Page 6: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Baas Service

• Custom objects • model, relationships and store/retrieve from central databases

• File storage • images, large documents, association with a custom object

• Geolocation • query object near a certain location

• Users • creation, integration with Facebook/Twitter, ACL for objects

• Push notifications • single way to push many platforms

6

Page 7: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Some examples

7

Page 8: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

8

Page 9: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

One backend to rule them all

9

Page 10: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Parse pricing

10

BASIC PRO ENTERPRISE

free $199 per month askRequests

1 Million/monthRequests

15 Million/monthCustom

Pushes 1 Million/month

Pushes 5 Million/month

Custom

File Storage 1 GB

File Storage 10 GB

Custom

App open metrics 1 concurrent background jobs !

2 App collaboratorAdvanced Push Targeting Push Scheduling …

Phone support Enterprise SLA Individual Push opens metrics …

Page 11: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

11

Parse Services

Page 12: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Parse Core

!

• Parse Dashboard

• Save data in the cloud

• Make your app social

• Run custom app code in the Parse Cloud

• Background jobs

12

Page 13: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Parse Push

!

• Push for: • iOS, Android, Windows, Windows Phone

• Send notification via: • web console, REST API, client SDKs !!!

• Advanced targeting (PRO, ENTERPRISE)

• Advanced scheduling (PRO, ENTERPRISE)

!

! 13

Page 14: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Parse Analytics

• Measure App usage

• Optimize Push Campaign

• Track Custom Analytics

• Powerful Dashboard

14

Page 15: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Let’s start!

15

Page 16: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

1 - Sign up for Parse

16

Page 17: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

2 - Create your first app

17

Page 18: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

3 - Dashboard

18

Page 19: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Setup SDK on iOS

• Download SDK • Latest version 1.2.18 • Support Xcode (5.0+) iOS 5.0 or higher

19

Page 20: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Connect you app to Parse

20

Page 21: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Data Browser

21

Page 22: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Parse Object

• Contains key-valued pairs of JSON-compatible data

• This data is schema-less • Each Parse Object has a class name !

PFObject in iOS • ParseObject in Android/Windows

22

Page 23: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Save an object

23

Auto generate Class!!!

Page 24: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Save an object

24

Page 25: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Special Class Name

• User • for authentication, log in, sign up and more

• Installation • store push notification subscriptions for each device

• Role • to specify groups of users with shared permissions

• Product • stores your in-app product data

25

Page 26: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Data Types

26

Page 27: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Some features

!Saving objects offline

!

!!!!Relational Data

27

Page 28: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Some features

28

!!!!!!Queries

!

!!!!

Page 29: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

User

• specialized user class called PFUser in iOS • several properties

• username (required) • password (required on signup) • email (optional)

• basic functionality: • sign up • login • email verification

29

Page 30: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Signing up

30

Page 31: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Loggin in

31

Page 32: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

PFLogInViewController

• Manage Login via PFLogInViewControllerDelegate !

- (BOOL)logInViewController:(PFLogInViewController *)logInController shouldBeginLogInWithUsername:(NSString *)username password:(NSString *)password; !- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user; !- (void)logInViewController:(PFLogInViewController *)logInController didFailToLogInWithError:(NSError *)error; !- (void)logInViewControllerDidCancelLogIn:(PFLogInViewController *)logInController;

32

Page 33: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

PFSignUpViewController

33

• Manage Sign up via PFSignUpViewControllerDelegate !

- (BOOL)signUpViewController:(PFSignUpViewController *)signUpController shouldBeginSignUp:(NSDictionary *)info; !- (void)signUpViewController:(PFSignUpViewController *)signUpController didSignUpUser:(PFUser *)user; !- (void)signUpViewController:(PFSignUpViewController *)signUpController didFailToSignUpWithError:(NSError *)error; !- (void)signUpViewControllerDidCancelSignUp:(PFSignUpViewController *)signUpController;

Page 34: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Facebook / Twitter integration

34

Page 35: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Facebook

• Setup FB application on developer.facebook.com

• Add App ID and App Secret on Parse settings

• Setup application follow https://developers.facebook.com/docs/ios/getting-started

• Adding this line on application:didFinishLaunchingWithOptions

!• Add also:

35

Page 36: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Facebook// Create the log in view controller PFLogInViewController *logInViewController = [[PFLogInViewController alloc] init]; [logInViewController setFacebookPermissions:[NSArray arrayWithObjects:@"friends_about_me", nil]]; ![logInViewController setFields: PFLogInFieldsTwitter | PFLogInFieldsFacebook | PFLogInFieldsDismissButton];

36

Page 37: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

User

37

Page 38: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Facebook / Twitter integration

• Login • Sign up • Linking existing PFUser to Twitter/Facebook • Unlinking existing PFUser to Twitter/Facebook • After authentication is possible to use:

• Query Graph on Facebook • Twitter API on Twitter

38

Page 39: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

• A bit of logic that running in the Cloud • Javascript SDK (same for apps) • You don't have to wait for a new release of

your application • Schedule jobs • Cloud Modules for integrate your Parse app

with third-party services and libraries39

Page 40: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Cloud Code

curl -s https://www.parse.com/downloads/cloud_code/installer.sh | sudo /bin/bash

40

• Install the command line tool

• Create new project

$ parse new MyCloudCode Email: [email protected] Password: 1:MyApp Select an App: 1 $ cd MyCloudCode

• A simple function in cloud/main.js

Parse.Cloud.define("hello", function(request, response) { response.success("Hello world!"); });

Page 41: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Cloud Code

41

$ parse deploy

• Deploy

• Run function on iOS

[PFCloud callFunctionInBackground:@"hello" withParameters:@{} block:^(NSString *result, NSError *error) { if (!error) { // result is @"Hello world!" } }];

• Response

{ "result": "Hello world!" }

Page 42: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Cloud Code

42

Page 43: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Web hosting

43

/public

index.html

Cloud Parse PRJ

Page 44: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

and now?

44

Parse Analytics

File storage

Push notifications Data relations

Users ACL

Geopoint

File storage

In-app purchase

Web hosting

Query

Email-verification

Page 45: Backend as a Service: Parse - Moriconi

ROME 11-12 april 2014 - Maurizio Moriconi

Thank You!

45

Backend as a Service: