Presentation is loading. Please wait.

Presentation is loading. Please wait.

Building Connected iOS Apps with Mobile Services Chris Risner Senior Technical Microsoft Azure.

Similar presentations


Presentation on theme: "Building Connected iOS Apps with Mobile Services Chris Risner Senior Technical Microsoft Azure."— Presentation transcript:

1 Building Connected iOS Apps with Mobile Services Chris Risner Senior Technical Evangelist @chrisrisner Microsoft Azure

2 About me 2 Technical Evangelist @chrisrisner Chrisrisner.com Live in Washington Grew up in Michigan Mobile dev for 5+ years

3 Agenda 3 Mobile ServicesFeatures and Demos Advanced FeaturesScaling and Pricing Questions

4 What is Mobile Services? 4 Storage Authentication Logic Push Scheduler

5 Demo: Getting Started Your first Mobile Service

6 Structured Storage Powered by SQL Database Supports rich querying capabilities Dynamic Schematization Data management in: Azure Portal SQL Portal (Silverlight) SQL Management Studio REST API Azure CLI Tools SQL CLI 6 Microsoft Azure

7 The REST API 7 ActionHTTP MethodURL Suffix CreatePOST/TodoItem ReadGET/TodoItem?filter=id%3D42 UpdatePATCH/TodoItem/id DeleteDELETE/TodoItem/id Microsoft Azure Base Endpoint: https://MobileService.azure- mobile.net/tables/*

8 JSON to SQL Type Mappings 8 JSON TypeT-SQL Type Numeric values (integer, decimal, floating point) Float(53) Booleanbit DateTimeDateTimeOffset(3) StringNvarchar(max) Microsoft Azure

9 Auto-generated Columns and Offline Auto-generated columns id – unique guid __createdAt – date __updatedAt – date __version – timestamp Helps with concurrency and offline Offline Bulit in support for storing data locally (SQLite) Tracks changes locally when disconnected Trigger sync when reconnected http://aka.ms/iOSOffline 9 Microsoft Azure

10 Backend Logic: JavaScript &.NET

11 Server Side Table Scripts 11 Node.js scripts Intercept CRUD requests to tables Passes through to SQL by default Fully customizable.NET Web API backend in Visual Studio MongoDB, Table Storage, SQL out of the box

12 Node Modules 12 request push.* console mssql tables azure sendgrid pusher twilio

13 Demo: Customizing Logic Adding Data Validation

14 .NET Backend Web API based w/ additional functionality, developed in and deployed from Visual Studio TableController data context can map to SQL, Table Storage, Mongo, etc Pull in NuGet modules and other.NET libraries Set permissions with attributes on classes Local Debug 14 Microsoft Azure

15 Custom API Non-table based endpoints Accessible from GET POST PUT PATCH DELETE For node.js logic in scripts like table endpoints For.NET delivered through a WebAPI Expose any functionality you want 15 Microsoft Azure

16 File Storage Don’t store files in Mobile Services DB Use Mobile Service to provide a Valet Key Pattern to Blob Storage, aka BLOB SAS Create table / custom API script to talk to Blob Storage Script generates Shared Access Signature (SAS) URL Script returns SAS URL to client app Client app uploads data to blob storage directly Store file URL in Mobile Service DB as needed Blob storage costs less and is built for redundant file storage 16 Microsoft Azure

17 Push Notifications

18 Push Notification Flow 18 Microsoft Azure Client (1) (2) (3) (4)

19 Demo: Adding Push Notifications

20 Notification Hubs Separate from Mobile Services Can be used regardless of whether you’re storing data in Azure Extremely scalable push notifications Cross platform support Push to iOS, Android, Kindle, Windows Phone, Windows Store Tags (i.e. tie my registration to this topic or user ID) Templates (i.e. when I get a push, send it in this format) Server SDKs for.NET, Java, and Node (also open as REST API) 20 Microsoft Azure

21 Authorization & Authentication

22 Data Authorization Per HTTP method auth options: App Key Required Not ideal for production use Everyone Authenticated Users Admins and other scripts Requires Master Key as header 401 Unauthorized response if security check fails 22 Microsoft Azure

23 User Auth Flow (server) 23 Microsoft Azure GOOGLE FACEBOOK TWITTER MOBILE SERVICE DEVICE CREDENTIALS (via oAuth/WebView) MICROSOFT ACCOUNT IDENTITY AUTH TOKEN GRAPH ACCESS (LIMITED) AAD

24 User Auth Flow (client) 24 Microsoft Azure GOOGLE FACEBOOK TWITTER MOBILE SERVICE DEVICE AUTH CODE AUTH CODE + TOKEN GRAPH ACCESS CREDENTIALS (via native SDKs) IDENTITY GRAPH ACCESS MICROSOFT ACCOUNT AAD

25 The User object User.level Admin Authenticated Anonymous User.userId Provider:id or undefined User.getIdentities() UserId Provider Access Token / Secret Basic user information (i.e. name, username, locale, picture, link) 25 Microsoft Azure

26 Demo: Adding Auth Lock Down and Login

27 Scheduler

28 Scheduled Jobs Executes a script on defined schedule Can be run on demand Ideal for any backend data processing job Length / frequency based of Mobile Service tier 28 Microsoft Azure

29 Script Source Control

30 Creates a Git repo in Azure Access table, scheduler, custom API, shared scripts and permissions Pushing changes triggers a redeploy of your Mobile Service Enables installing NPM modules (for Node backends) Shared Scripts Create scripts that can be used from all other scripts in your Service 30 Microsoft Azure

31 Diagnostics Logging Scale

32 Diagnostics, Logging, Scale 32 API Calls, # of Devices, Data Out Console Logging (auto error logging) Scale Service Based off API Calls Auto-scale to Save Money Free Tier for Mobile Free Tier for SQL

33 Mobile Service Scaling  Free: 500k calls / month / subscription  Basic: 1.5M calls / unit (6) / month  Standard: 15M calls / unit (10) / month Microsoft Azure

34 Demo: Scaling Leaving Free Mode and Turning on AutoScale

35 Command Line Interface

36 CLI 36 Create / Delete Services Inspect / Delete Table Data Create / Update / Delete Tables and Permissions Create / Upload / Delete Scripts Scale Up / Down Services Much More Across Azure

37 Demo: Using the CLI

38 Mobile Service Tiers 38 $ General Availability 99.9% FreeBasicStandard Usage Restrictions Up to 10 services, Up to 500 Active Devices* N/A API Calls500K (per subscription) 1.5M (per unit) 15M (per unit) ScaleN/AUp to 6 (in portal)Up to 10 (in portal) Scheduled Jobs LimitedIncluded SQL Database (required) 20MB free DB *Active devices refers to the number of physical devices and emulators that make at least one call to or receive a push notification from your mobile service.

39 Azure Mobile Services 39 Storage Authentication Logic Push Scheduler

40 Mobile Services Resources Get a FREE Microsoft Azure Trial Account: http://azure.microsoft.com Videos, Tutorials, and More http://azure.microsoft.com/iOS SDK Source Code on GitHub https://github.com/Azure/azure-mobile-services Contact Details mobileServices@microsoft.com @chrisrisner 40 Microsoft Azure

41 Hybrid Connections

42 Web Sites Mobile Services Corporate Network Microsoft SQL Server Hybrid Connection Other published resources Hybrid Connection Manager

43 Notification Hubs

44 Push Notification Flow (again) 44 Microsoft Azure Client (1) (2) (3) (4)

45 Notification Hubs deals with Storing device registration information Signing push requests and sending to PNS Dealing with invalid push ID registrations Handling templates and tags You just need to Configure your hub and app Register with the PNS Pass along the push ID Managed

46 1.App registers with provider 2.App gets token 3.App sends token to Hub 4.Push requested 5.Hub delivers push to provider 6.Provider pushes to device Hub handles expired tokens Using Notification Hubs APNs WNS Notification Hub App back-end iOS app Windows app MPNSGCMADM

47 Demo: Hubs Creating a Hub Configuring a Hub Register and Push

48 Tags

49 Clients register with set of tags Tags are strings tied to the Push ID Requests to push to a Tag will push to connected Push IDs “Interest based push” Tags

50 Tags: Example Notification Hub App back-end Tag:”Tablet” Tag:”Phone” Tag:”Tablet”

51 Conference name Username Zip code Sports team Band name Stock ticker Other Tag Usages

52 Demo: Tags Registering with Tags Pushing with Tags

53 Logic based tag pushed Social: “All of this group but me” Group:id && !user:id Version and platform Version:1.0 && platform:iOS Events: “Anyone interested in the game” FollowTeam:SeaHawks || FollowTeam:Broncos || EventInterest:SuperBowl Tag Expressions

54 Templates

55 Clients can specify templates when registering Templates specify format of payload when specific push is sent If “Message” push is sent, send it in this format { alert : “$info” } Enables app backend to send platform independent messages i.e. push to all the devices with this tag Multiple templates per device Different tags per template Templates

56 Demo: Templates Registering with Templates Push to all the devices!

57 Client vs Server Registration

58 Client app talks directly with Notification Hub Sends over the wire Push ID (Channel URI, Registration ID, Token) Tags Templates Notification Hub Listen Connection String Not completely secure Registering from the Client

59 Authenticate the request before registering Is the user who they say they are? Can still specify tags and templates Great for setting up registrations from a web app Good for when an app update requires a user’s registrations being updated i.e. manager adding an employee to a group Registering from the Server

60 Notification Hub App back-end {id} upsert({id}, channel, tags) createId()

61 Notification Hubs Resources Get a FREE Microsoft Azure Trial Account: http://azure.microsoft.com Check out Notification Hubs http://aka.ms/NH SDK Source Code on GitHub https://github.com/Azure/azure-notificationhubs Contact Details http://chrisrisner.com http://aka.ms/CommonWams @chrisrisner 61 Microsoft Azure

62 Get started Visit azure.microsoft.com

63


Download ppt "Building Connected iOS Apps with Mobile Services Chris Risner Senior Technical Microsoft Azure."

Similar presentations


Ads by Google