Sviluppare la parte server di un'applicazione mobile in maniera veloce e semplice attraverso uno dei servizi BaaS più popolari: Parse. Acquisito da Facebook lo scorso anno, supporta le maggiori piattaforme mobili offrendo i servizi di: - gestione utenti (login, registrazione) - gestione social (facebook, twitter) - push notification (iOS, Android, Windows 8, Windows Phone) - persistenza dei dati - file storage Il talk vuole presentare il servizio con un esempio completo di utilizzo in ambiente iOS.
1. ROME 11-12 april 2014ROME 11-12 april 2014
Backend as a Service: Parse
maurizio.moriconi@mobilesoft.it
Maurizio Moriconi
2. 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
3. ROME 11-12 april 2014 - Maurizio Moriconi
Develop an app
Push Notification
Analytics
User management
Social integration
Shared data
Web Hosting
Database hosting
3
4. ROME 11-12 april 2014 - Maurizio Moriconi
Challenges
!
• Time
• Skill
• Scalability
• Cost
4
5. 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
6. 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
12. 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
22. 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
23. ROME 11-12 april 2014 - Maurizio Moriconi
Save an object
23
Auto generate Class!!!
25. 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
27. ROME 11-12 april 2014 - Maurizio Moriconi
Some features
!
Saving objects offline
!
!
!
!
!
Relational Data
27
28. ROME 11-12 april 2014 - Maurizio Moriconi
Some features
28
!
!
!
!
!
!
Queries
!
!
!
!
!
29. 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
35. 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
38. 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
39. 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 libraries
39
40. 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: ninja@gmail.com
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!");
});
41. 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!"
}