+ All Categories
Home > Technology > Windows Azure Mobile Services

Windows Azure Mobile Services

Date post: 12-Dec-2014
Category:
Upload: sasha-goldshtein
View: 549 times
Download: 1 times
Share this document with a friend
Description:
Presentation from ConFoo 2014 on Windows Azure Mobile Services. Introducing the platform, building out an application that uses data storage, server-side scripts, custom API endpoints, push notifications, and client authentication. Source code is available on GitHub at http://github.com/goldshtn/rentahome
Popular Tags:
17
© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com Sasha Goldshtein @goldshtn CTO, SELA Group blog.sashag.net Windows Azure Mobile Services
Transcript
Page 1: Windows Azure Mobile Services

© Copyright SELA software & Education Labs Ltd. | 14-18 Baruch Hirsch St Bnei Brak, 51202 Israel | www.selagroup.com

Sasha Goldshtein @goldshtnCTO, SELA Group blog.sashag.netWindows Azure Mobile Services

Page 2: Windows Azure Mobile Services

Who Are We? App DevelopersWhat Do We Hate? Backends

Page 3: Windows Azure Mobile Services

We need one backend for all our mobile apps, scaled by the cloud

Oh, and it should cost about $0-5 / month for a small, simple app

Page 4: Windows Azure Mobile Services

Backend as a Service

Windows 8 & Windows PhoneiOS & AndroidHTML & JavaScriptData & LINQ queriesServer scripts, schedulerAuthentication & WAADNEW

Custom APINEW

Source control and NPMNEW

Push, notification hubsNEW

Page 5: Windows Azure Mobile Services

Demo

Windows Azure Mobile Services Portal

Page 6: Windows Azure Mobile Services

Initializing The Mobile Service Client

Windows 8 / Windows Phone / AndroidiOS

ms = new MobileServiceClient("https://rentahome.azure-mobile.net","..." /*API key*/);

ms = [MSClient clientWithApplicationURLString:"https://rentahome.azure-mobile.net"

applicationKey:"..."];

The application key is for development purposes only. In production, use user authentication to limit access to data

Page 7: Windows Azure Mobile Services

Accessing Data

// Windows 8 and Windows Phonevar apartments = await ms.GetTable<Apartment>() .Where(a => a.Bedrooms > 2).ToListAsync();

// Androidms.getTable(Apartment.class).where(). .field("bedrooms").gt(2).execute(...);

// iOSNSPredicate *pred = [NSPredicate predicateWithFormat:@"bedrooms > 2"];[[client getTable:@"apartment"] readWhere:pred completion:^...];

Page 8: Windows Azure Mobile Services

Server Scripts

CRUD operations can pass through a custom script

Use for validation, data enrichment, etc.Scripts are written in JavaScript and run on Node.jsCan access several Node modules: request, push, …

function insert(item, user, request) { if (item.address.length === 0) { request.respond(400); } else { request.execute(); }}

Page 9: Windows Azure Mobile Services

Custom API

Add custom HTTP endpoints to your mobile serviceVery useful for external access

exports.post = function(request, response) { sharedHub.send_ad(request.body.message, function(error)

{ if (error) { response.send(500, 'Error sending ad: ' + error); } else { response.send(200); } });};

Page 10: Windows Azure Mobile Services

Demo

Enriching Data with Server Scripts

Page 11: Windows Azure Mobile Services

Push

On trigger, send push from scriptUnfortunately, push API differs for each platform

Prepare app for push notificationsDepends on platform

push.wns.sendToast02(channel.uri, { text01: "New apartment added", text02: apartment.address });

Channel = await PushNotificationChannelManager. CreatePushNotificationChannelForApplicationAsync();channelsTable.Insert(new Channel(Channel.Uri));

Page 12: Windows Azure Mobile Services

Notification Hubs

Blast out push messages based on the template and the tagsRegister templates for push notifications with arbitrary custom tags

var payload = { message : message };hub.send(tag, payload, function(error, outcome) { ... });

template = { data: { message: '$(message)' } };hub.gcm.createTemplateRegistration(request.body.uri, tags, template, registrationComplete);

Page 13: Windows Azure Mobile Services

Demo

Server-Side Push Support

Page 14: Windows Azure Mobile Services

Authentication

// iOSif (!client.currentUser) { [self presentViewController:[client loginViewControllerWithProvider:@"twitter" completion:(MSUser *user, NSError *err) ... ] animated:YES];}

// Androidif (client.getCurrentUser() != null) { client.login( MobileServiceAuthenticationProvider.Twitter, new UserAuthenticationCallback() ...);}

Page 15: Windows Azure Mobile Services

Demo

Authentication

Page 16: Windows Azure Mobile Services

Summary

Windows Azure Mobile Services provide a powerful and customizable backend for your mobile appsCode available at http://github.com/goldshtn/rentahome

Page 17: Windows Azure Mobile Services

QuestionsSasha Goldshtein @goldshtnCTO, SELA Group blog.sashag.net


Recommended