Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mobile Backend as a Service

Mobile Backend as a Service

Mobile Backend as a Service

jmortegac

April 26, 2015
Tweet

More Decks by jmortegac

Other Decks in Programming

Transcript

  1. José Manuel Ortega Candel
    Mobile Backend as a Service(MBaaS)
    Except where otherwise noted, this work is licensed under: http://creativecommons.org/licenses/by-nc-sa/3.0/
    Leganés
    12-13 Febrero 2015

    View Slide

  2. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    2
    https://speakerdeck.com/jmortega

    View Slide

  3. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    3
    Persistence in Mobile
    iNDEX
    Cloud Computing / BaaS
    MBaaS features /architecture/ Startups
    Push Notifications / GCM / API REST / Storage
    Kinvey / Backendless / BackBeam / Parse
    Demos on Android

    View Slide

  4. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    4
    SQLite / Core Data
    Persistence in Mobile

    View Slide

  5. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    5
    Persistence in Mobile
    Android iOS
    SQLite
    android.database.sqlite
     Tables and relations
    Core Data
     Objects
     DataModel
    Content Providers
    /data/data/
    /databases/ Only
    acces with root
    DataModel editor in Xcode for
    register objects and their
    relationships

    View Slide

  6. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    6
    Persistence in Mobile
    Objects vs Tables
    Object Relational Mapping

    View Slide

  7. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    7
    Persistence in Mobile
    public class Event extends Entity {
    public int id;
    public String name;
    }
    Event e =
    Entity.query(Event.class).where("id=1")
    .execute();
    p.name = “Techfest";
    p.save();

    View Slide

  8. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    8
    Cloud Computing
    PaaS(Platform as a Service)
    IaaS(Infraestructure as a Service)

    View Slide

  9. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    9
    Cloud Computing
    BaaS(Backend as a Service) /MBaaS
    SaaS(Software as a Service)

    View Slide

  10. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    10
    BaaS

    View Slide

  11. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    11
    BaaS
    MBaaS= Cloud-Mobile Services + Mobile SDKs + Management Console

    View Slide

  12. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    12
    MBaaS APIs

    View Slide

  13. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    13
    MBaaS APIs

    View Slide

  14. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    14
    MBaaS architecture

    View Slide

  15. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    15
    MBaaS features
     API REST for CRUD operations(GET,POST,UPDATE,DELETE,PATCH)
     Multi platform SDK
     Cloud Storage
     Push notifications
     User management
     Data Browser
     Query language
     Import/Export data
     Analytics / Monetization

    View Slide

  16. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    16
    MBaaS features
    Reduce server side coding
    developers can focus on front-end development
    often providers offer SDKs that wrap REST API calls
    and handle in/out parameters:
    both HTML/JS and native (iOS, Android,Windows
    Phone)
    No server setup, ready to use (HOSTED SERVICE)
    Deployed on the cloud, with built-in scalability

    View Slide

  17. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    17
    Startups

    View Slide

  18. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    18
    Others
     Appcelerator(Titanium)
     http://appery.io
     http://www.applicasa.com
     http://www.apiomat.com
     http://www.kumulos.com
     Open Source
     http://www.baasbox.com

    View Slide

  19. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    19
    Startups

    View Slide

  20. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    20
    MBaaS
    OBJECT-BASED DATA STORAGE
    DATA SYNCHRONIZED
    USER ACCOUNTS & AUTHENTICATION
    REAL-TIME ANALYTICS
    PUSH NOTIFICATIONS
    API REST

    View Slide

  21. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    21
    Storage support

    View Slide

  22. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    22
    { "results": [
    {
    "createdAt": "2015-01-05T14:54:00.650Z",
    "eventImage": {
    "__type": "File",
    "name": "tfss-b84799aa-4366-488d-afe7-1afdb5646dee-t3chfest_slider.jpg",
    "url": "http://files.parsetfss.com/5ffebb1f-a86a-4d00-8dcb-6b9e349f4838/tfss-b84799aa-4366-
    488d-afe7-1afdb5646dee-t3chfest_slider.jpg" },
    "eventName": "techFest",
    "eventURL": "https://techfest.uc3m.es/",
    "objectId": "HxmPtSWnqa", "updatedAt": "2015-02-12T14:56:00.866Z" }] }
    JSON Object

    View Slide

  23. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    23
    Push Notifications
    Var channel= _application.pubSub.Subscribe(“channel
    name”);
    channel.Send({message});
    Push Notification
    Service
    MBaaS

    View Slide

  24. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    24
    Push Notifications
     Multiplatforms messages
     Enable server applications to send information to mobile
    apps even when the app isn’t in use
     The device displays the information using a “badge,” alert, or pop
    up message. A push notification uses the service provided by the
    device’s operating system:
     iOS - Apple Push Notification service (APNS)
     Android - Google Cloud Messaging (GCM)

    View Slide

  25. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    25
    Google Cloud Messaging(GCM)

    View Slide

  26. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    26
    Google Cloud Messaging(GCM)
    https://console.developers.google.com

    View Slide

  27. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    27
    Push Notifications
    iOS
    Apple Push Notification service (APNs) Certificate
    Private Key
    Android
    Google Cloud Messaging API KEY
    Sender ID
    Google API Console > Authentication && Project
    Number

    View Slide

  28. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    28

    View Slide

  29. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    29
    Kinvey Data collection
    Kinvey stores data as collections and entities. Entities are JSON documents. Collections belong to
    applications. Internally, data is stored in a MongoDB cluster.

    View Slide

  30. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    30
    Kinvey Data management
    NO SQL DataBases
    REST API
    CLOUD CODE

    View Slide

  31. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    31
    Kinvey Data Link

    View Slide

  32. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    32
    Kinvey API REST

    View Slide

  33. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    33
    Kinvey API REST OPERATIONS

    View Slide

  34. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    34
    Kinvey API REST OPERATIONS

    View Slide

  35. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    35
    Kinvey CLOUD CODE
     JavaScript / Custom endpoints

    View Slide

  36. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    36
    Kinvey Users management

    View Slide

  37. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    37
    Kinvey Import/Export data

    View Slide

  38. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    38
    Kinvey Push notifications

    View Slide

  39. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    39
    Kinvey

    View Slide

  40. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    40

    View Slide

  41. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    41
    BackBeam

    View Slide

  42. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    42
    BackBeam

    View Slide

  43. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    43
    BackBeam

    View Slide

  44. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    44

    View Slide

  45. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    45
    Backendless Data Browser

    View Slide

  46. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    46
    Backendless data type & relations

    View Slide

  47. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    47
    Backendless Export data

    View Slide

  48. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    48
    Backendless generate code

    View Slide

  49. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    49
    Backendless Project

    View Slide

  50. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    50
    Backendless Project

    View Slide

  51. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    51
    Backendless security

    View Slide

  52. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    52
    Backendless security

    View Slide

  53. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    53
    Backendless User managment
    BackendlessUser user = new BackendlessUser();
    user.setEmail( “[email protected]" );
    user.setPassword( "my_super_password" );
    Backendless.UserService.register( user, new BackendlessCallback()
    {
    @Override
    public void handleResponse( BackendlessUser backendlessUser )
    {
    Log.i( "Registration", backendlessUser.getEmail() + " successfully registered" );
    }
    } );

    View Slide

  54. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    54

    View Slide

  55. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    55
    Security
    Authentication && Authorization
    Basic Authentication userName and password encoded in
    Base 64
    authorization
    header: Authorization: Basic
    bXlVc2VybmFtZTpteVBhc3N3b3Jk
    Session Authentication Auth token / Social Networks
    Permissions Shared / Private / Read Only / Full

    View Slide

  56. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    56

    View Slide

  57. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    57
    Parse ARCHITECTURE

    View Slide

  58. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    58
    Parse SERVICES
    User Authentication
    Push Notification
    Data Storage
    Rest API
    JavaScript SDK
    iOS SDK
    Android SDK
    JavaScript SDK

    View Slide

  59. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    59
    Parse CROSS-PLATFORM SUPPORT

    View Slide

  60. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    60
    Connect your app with services
    APPLICATION ID
    CLIENT KEY
    + Parse.initialize(“APP_ID”,”C_KEY”);

    View Slide

  61. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    61
    Parse Application Keys + Installations

    View Slide

  62. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    62
    Parse Objects
    Parse stores data internally as flat JSON Documents, called ParseObject, with have the restriction that
    keys must be alphanumeric strings. Parse automatically creates ‘classes’ for ParseObjects, grouping objects
    with similar properties. Classes and all objects associated to them belong to applications, which can be
    defined on the Parse web interface.
    ParseObject event = new ParseObject(“Event");
    event.put(“eventName", “techfest”);
    event.put(“eventURL", “http://techfest.uc3m.es");
    event.put(“eventDate", new Date());

    View Slide

  63. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    63
    Parse Data browser + filter

    View Slide

  64. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    64
    Parse Data browser

    View Slide

  65. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    65
    Parse Cloud Code
     Write our owns API functions with javascript

    View Slide

  66. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    66
    Parse with ANDROID


    // Enable Local Datastore.
    Parse.enableLocalDatastore(this);
    Parse.initialize(this, “APPLICATION_ID", “CLIENT_KEY");
    ParseObject event = new ParseObject(“Event");
    event.put(“eventName", “techfest”);
    event.put(“eventURL", “http://techfest.uc3m.es");
    event.put(“eventDate", new Date());
    event.saveEventually(); //Object saved when user has network connection
    event.saveInBackground();

    View Slide

  67. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    67
    Parse Object
    import com.parse.ParseClassName;
    import com.parse.ParseObject;
    @ParseClassName(“Event")
    public class Event extends ParseObject{
    public Event(){}
    public String getName(){
    return getString(“eventName");
    }
    public void setName(String name){
    put(“eventName", name); }
    }}
    ParseObject.registerSubclass(Event.class);

    View Slide

  68. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    68
    Parse Object with files
    byte[] data = myPhotoObject.toByteArray();
    ParseFile eventPhoto = new ParseFile("t3chfest.jpg", data);
    eventPhoto.saveInBackground();
    ParseObject event = new ParseObject("Event");
    event.put("name", "t3chFest");
    event.put(”photo”, eventPhoto);
    event.saveInBackground();

    View Slide

  69. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    69
    Parse Object with files

    View Slide

  70. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    70
    Parse Data Entity type

    View Slide

  71. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    71
    Query Language
    ParseQuery query = ParseQuery.getQuery(“Event");
    query.whereEqualTo(“eventName", “techfest");
    query.findInBackground(new FindCallback() {
    public void done(List eventList, ParseException e) {
    if (e == null) {
    Log.d(“events", "Retrieved " + eventList.size() + " events");
    } else {
    Log.d(“events", "Error: " + e.getMessage());
    }
    }
    });
    query.setCachePolicy(CachePolicy.CACHE_THEN_NETWORK);

    View Slide

  72. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    72
    CACHE
     query.cachePolicy property
     CachePolicy.CACHE_ELSE_NETWORK
    The query first tries to load from the cache, but if that fails, it loads results from
    the network.If neither cache nor network succeed, there is a PFError.
     CachePolicy.CACHE_THEN_NETWORK
    The query first loads from the cache, then loads from the network. In this case,
    the callback will actually be called twice - first with the cached results, then with
    the network results.
    Since it returns two results at different times, this cache policy cannot be used
    synchronously with findObjects.

    View Slide

  73. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    73
    JavaScript
    var event= Parse.Object.extend ("Event");
    var query = new Parse.Query (event);
    query.find ({ success: function (results) {
    $scope.data.events = results;
    },
    error: function (error) {
    alert ("Error:" + error.code + "" + error.message);
    }
    });

    View Slide

  74. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    74
    Parse Push Notifications
    Enabling Push Notifications

    View Slide

  75. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    75
    Parse SDK

    View Slide

  76. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    76
    Parse Push Notifications

    View Slide

  77. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    77
    Parse Push Notifications
    //Enable to receive push
    PushService.setDefaultPushCallback(this,
    RespondToPushActivity.class);
    ParseInstallation pi = ParseInstallation.getCurrentInstallation();
    //Register a channel to test push channels
    Context ctx = this.getApplicationContext();
    PushService.subscribe(ctx, "ch1", RespondToPushActivity.class);
    pi.saveEventually();

    View Slide

  78. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    78
    API REST

    View Slide

  79. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    79
    API REST AJAX CALL
    var headers = {"X-Parse-Application-Id":"YOUR-APP-ID-HERE", "X-Parse-REST-API-Key":"YOUR-
    REST-API-KEY-HERE"};
    function getData() {
    $.ajax({ "type":"GET", "url":"https://api.parse.com/1/classes/Event",
    "dataType":"json", "contentType":"application/json", "headers":headers,
    success:function(data, status, xhr) {
    var result = "";
    for(var i = 0; i < data.results.length; i++) {
    result = result +""+ data.results[i].eventName+" / "+ data.results[i].eventURL+"";
    }}
    });
    }

    View Slide

  80. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    80
    PERMISSIONS / ACL

    View Slide

  81. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    81
    PARSE ANALYTICS

    View Slide

  82. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    82
    PARSE IMPORT DATA JSON/CSV

    View Slide

  83. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    83
    PARSE USER MANAGMENT
    //login
    ParseUser.logInInBackground(username, password, new LogInCallback() {
    public void done(ParseUser user, com.parse.ParseException e) {
    }});
    //signUp
    ParseUser user = new ParseUser();
    user.setUsername(username);
    user.setPassword(password);
    user.setEmail(email); //optional
    user.signUpInBackground(new SignUpCallback() {
    public void done(com.parse.ParseException e) {
    }});
    //Check if user is logged
    ParseUser currentUser = ParseUser.getCurrentUser();

    View Slide

  84. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    84
    PARSE USER MANAGMENT

    View Slide

  85. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    85
    https://github.com/jmortega/parseProjects

    View Slide

  86. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    86
    Parse T3chfest

    View Slide

  87. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    87
    Parse T3chfest

    View Slide

  88. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    88
    Parse Login

    View Slide

  89. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    89
    PARSE EXAMPLES https://parse.com/tutorials

    View Slide

  90. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    90
    REFERENCES http://www.androidbook.com/expertandroid/projects

    View Slide

  91. Mobile Backend as a Service(MBaaS)
    Leganés
    12-13 Febrero 2015
    91

    View Slide