Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
Agenda
Mobile ServicesOverall introduction
JavaScript backend (data access, server side script, auth, custom API)
.NET backend (data access, offline support, on-premise connection)
Notification Hubs UpdatesMobile Push Notifications 101
Notification Hubs with Mobile Services
Targeted notifications with tags
Mobile Services Investment Areas
1. Consumer-Facing Apps in Organizations
2. Employee-Facing Apps in Organizations
Mobile Service
Windows Store
iOS
Android
Xamarin
Windows Phone
iOS
Android
HTML 5/JS
SDKs
Node.js
REST A
PI
Facebook Twitter Microsoft GoogleActive
Directory
SQLTable
storageBlob
storage
WNS & MPNS
APNS GCM
Mongo DB
Notification Hubs
Source Control
Azure Models
开发及部署的便利性
定制
化能
力
Virtual Machines
Cloud Services
Websites
Mobile Services
直接迁移虚机
全功能多层框架
快速部署和扩展
最快速的移动服务端框架
Action HTTP Verb URL Suffix
Create POST /TodoItem
Retrieve GET /TodoItem?$filter=id%3D42
Update PATCH /TodoItem/id
Delete DELETE /TodoItem/id
http://Mobileservice.azure-mobile.net/tables/*
Auto-generated Columns
Column Type
ID GUID
CreatedAt DateTime
UpdatedAt DateTime
Version Timestamp
Compute
JSON Value T-SQL Type
Numeric values
(integer, decimal, floating point)
Float
Boolean Bit
DateTime DateTimeOffset(3)
String Nvarchar(max)
Core objective of .NET Mobile Services:
Enable enterprise .NET developers
to easily add a backend to their apps,
use their preferred frameworks, tools, and
processes
source
Mobile Services
compatible WebAPI
controllers
git
WebDeploy
Commit hook:
Build project
Website
XDRIVE\site\wwwroot
Mobile Services
compatible WebAPI
controllers
Web.config
C:\...\MobileServices
Mobile Services
runtime
Web.config
website root
load
User database:
EF code-first migrations
or custom migrations
App settings
injected here
TableController
DataManagerDTO
DTO
Mobile ServiceDevice
Model
AutoMapper
SQL Azure/BYOD
Existing
Tables
System
Properties
Table
Mobile Services Offline Support
• Lightweight
• Cross-platform Currently support only .NET, but iOS and Xamarin are coming
• “Occasionally-connected” scenarios
• Support multiple backend data storesE.g., SQL, Azure Tables, Mongo, etc.
• Support both Node.js and .NET backends
TableController
(with optimistic
concurrency)
Mobile ServiceDevice
SQL Database
BYOD
MongoDB
Table Storage
SQLite
Explicit Push/Pull
Conflict resolution
What Mobile Services Offline is Not
• Not a database-to-database sync solution
• Not intended to supplant full-featured sync frameworks
Often specialized to particular backend stores
Often specialized to particular client frameworks/languages
• Not exclusive. You can use 3rd party Offline framework
As long as hey work with Web API. E.g. Breeze.js.
Conflict Resolution
▲, 1
▲, 1▲, 1■, 2
Device 1 Server Device 2
▲, 1 ▲, 1
▲, 1 ▲, 1
▲, 1
●, 2 ■, 2
▲, 1
Create
Fetch
■, 2Update
Update■, 2✘
Azure Active Directory
• Extend line-of-business to mobile
• Bring turn-key login experience with corporate credentials to mobile developers
• Enable applications built around organizational structures
• Make AAD users a first-class concept in Mobile Services, with push-to-user and per-user data
Active Directory Authentication Library (ADAL)
• Facilitates login to AAD-protected resources
• Provides single sign-on to multiple enterprise resources
• Available for Windows Store, iOS, and Android
1. Client app uses ADAL to initiate login, user enters credentials which are sent to AAD
2. AAD returns an Access Token / Refresh Token pair for the mobile service to ADAL
3. The client passes the Access Token to the mobile service, exchanges for the Mobile Services token for a continued session
Basic ADAL + Mobile Services Flow
3
2
1
BizTalk Services Hybrid Connections
Microsoft Azure Your Enterprise
Connection string points to My-Database:1433
Hybrid Connection Manager
My-Database
1433
JavaScript .NET
Developer
Experience
Script based, develop in Azure portal on-the-fly,
relay on Node.js module and Express.js
Using C#, develop and publish in VS, host by
an updated version of ASP.NET Web API by
removing some unnecessary dependency,
Data Model By default support SQL Database and make it a
simple experience in basic scenarios.
Support SQL Server, Azure Storage and
MongoDB, rely on EF to access SQL Server,
but very easy to switch to other
DomainManager to support different storage.
Custom API Rely on Express.js Rely on APIController from ASP.NET
Push Notification Could send notification to specific provider or
using Notification Hub to push to all platform
Only through Notification Hub
Debug Only through logging and check the log in the
portal
Fully integrated with VS for local and remote
debugging
Portal Difference No Data or Script tab on the portal since data
access and custom logic are both
implemented in C#
Mobile Service Backend Comparison
Mobile push is everywhere
Reservation changes, Deals, Back-office
Travel/Hospitality/Airlines
SMS replacement, Deals, Back-office
Banking/Insurance
Orders, Product UX,
Back-office
Discrete manufacturing/Auto
Prescriptions, Appointments,
LOB (maintenance)
Healthcare
Breaking news
News/Media
Offers, Orders, Back-office
Retail
Push notification lifecycle
Registration at app launchClient app contacts Platform Notification Service, to retrieve current channel (e.g. ChannelURIs, device tokens, registrationIds)
App updates handle in back-end
Sending NotificationApp back-end send notification to PNS
PNS pushes the notification to the app on the device
MaintenanceDelete expired handles when PNS rejects them
Platform
Notification
Service
App back-end
Challenges of push notifications
Platform dependencyDifferent communication protocols (e.g. HTTP vs TCP, xml vs json)
Different presentation formats and capabilities (alerts vs tiles vs toasts vs badges)
RoutingPNS’ provide a way to send a message to a device/channel
Usually notifications are targeted at users or interest groups (e.g. employees assigned to a customer account)
App back-end has to maintain a registry associating device handles to interest groups/users
ScaleApp back-end has to store handles for each device high storage and VM costs
Broadcast to millions of devices with low latency requires parallelization (DB ad VM)
Advantages of using Notification Hubs
X-plat: from any back-end to any mobile platformBackend can be on-prem or in the cloud, .NET/Node/Java/PHP/Node/anything.
Support Windows Phone/Windows/iOS/Android and Kindle Fire.
No need to store device information in the app back-endNotification Hub maintains the registry of devices and the associations to users/interest groups
Routing and interest groupsTarget individual users and large interest groups using tags
Personalization and localizationKeep your back-end free of presentation concerns like localization and user preferences using templates
Broadcast at scale, multicast, unicastPush notifications to millions of devices (across platforms) with a single call
TelemetryRich telemetry available through portal or APIs
Using Notification Hubs
One-time set up1. Create a Notification Hub
Register1. The client app retrieves its current handle from the PNS
2. Client app creates (or updates) a registration on the Notification Hub with the current handle
Send Notification1. The app back-end sends a message to the Notification Hub
2. Notification Hub pushes it to the PNS’
APNs WNS
Notification Hub
App back-end
iOS app Windows app
MPNS
GCM
ADM
Powered by Notification HubsAccess broadcast at scale, push to user and interest groups, localization templates and more…
No more Channels tableSimple two steps process to push notifications, no data handling
1 Unit of Notification Hubs included for free
Node.js and .NET
New push engine for Mobile Services
Some snippetsRegister Send
Windows / Windows Phoneawait hub.RegisterNativeAsync(channel.Uri);
iOS[hub registerNativeWithDeviceToken:deviceToken
tags:nilcompletion:^(NSError* error) { … }];
Android / Kindlehub.register(regid);
.NETvar toast = @“<notification payload>";hub.SendWindowsNativeNotificationAsync(toast);
Node / Mobile ServiceshubService.wns.sendToastText01(null,
{text1: 'Hello from Node!'
},function (error)
{…
});
Tags
Tags as interest groupsClient app can register with a set of tags
Tags are simple strings (no pre-provisioning is required)
App back-end can target all clients with the same tag
You can use tags also forMultiple type of interest groups, e.g.
Follow bands: tag “followband:Beatles”
Follow users: tag “followuser:Alice”
Tag devices with a user id
Notification Hub
App back-end
Tag:”Beatles”Tag:”Wailers”
Tag:”Beatles”
Some snippets
await new string[] {"myTag", "myOtherTag"}
[hub registerNativeWithDeviceToken:deviceToken tags:@[@"myTag", @"myOtherTag"] completion:^(NSError* error) {…
}];
hub.register(regid, "myTag“, "myOtherTag");
Tag expressions
Social “All my group except me”
group:id && !user:id
Events Touchdown event is send to everybody following either team
Followteam:A || Followteam:B || followplayer:1 || followplayer:2 …
Hours Send notifications at specific times. E.g. Tag with timezone, @12pm in Seattle send:
timezone:PST && follows:thaifood
Versions & platforms Send a reminder to update to your first Android app version:
version:1.0 && platform:Android
From Mobile Services
Maintains Notification Hubs’ surfaceCall register to register tags from the device
Push from your scripts
push.wns.sendToastText04(
null,
{ text1: ‘Hello!’ },
{ success: function()
{ console.log("Sent push"); }
});
MobileService.Push.RegisterNativeAsync(channel);
© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Office, Azure, System Center, Dynamics and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.