430 likes | 627 Vues
Building Cloud-Connected iOS, Android and Windows Apps. Kirill Gavrylyuk | Principal Program Manager Lead, Azure Mobile Miranda Luna | Product Manager, Azure Mobile. Course Topics. Please leave this area blank to allow for picture in picture recording. Setting Expectations. Target Audience
E N D
Building Cloud-Connected iOS, Android and Windows Apps Kirill Gavrylyuk | Principal Program Manager Lead, Azure Mobile Miranda Luna | Product Manager, Azure Mobile
Please leave this area blank to allow for picture in picture recording Setting Expectations • Target Audience • Developers building iOS, Android and Windows apps, whether natively or with a cross-platform framework • Suggested Prerequisites/Supporting Material • MVA Consumer Mobile Apps that Scale • Channel9 Azure Mobile Services Learning Series • aka.ms/CommonWAMS
Join the MVA Community! • Microsoft Virtual Academy—Free online training! • Ask questions in the Born to Learn MVA Forum! • Visit http://aka.ms/MVAForum • Earn while you learn! • 50 MVA Points for this event! • Visit http://aka.ms/MVA-Voucher • Code: BldgBlks3
Push Notifications Mobile push notification engine for existing apps Enhance push notifications in any app with personalization and localization Improves user engagement and retention by delivering relevant content more quickly Mobile Backend Ready-made mobile app backend for iOS, Android and Windows Create new mobile apps or add a mobility layer to existing systems Speeds up development time and reduces ongoing maintenance cost Device Messaging Messaging infrastructure that sits between and within applications Build multi-tier and hybrid applications or smart device information exchange patterns Delivers inter- and intra-app messages faster and connects on-premises systems to the cloud
Mobile Services Overview Mobile Services App Backend can be Node.js or .NET Store Data in the Cloud SDKs Windows Store iOS Android Xamarin Sencha Windows Phone iOS Android HTML 5/JS Custom Code .NET Web API Node.js Express Table Storage Blob Storage Mongo DB SQL User Authentication REST API Active Directory Facebook Twitter Microsoft Google Push Notifications Source Control WNS & MPNS Notification Hubs APNS GCM
Supported Platforms Sencha Touch Native iOS Xamarin (iOS & Android in C#) Native Android Native Win8/ WinPhone HTML5/ Javascript
Please leave this area blank to allow for picture in picture recording LensRocket • A single mobile service can power multiple client apps • LensRocket sample • iOS App Store: aka.ms/LensRocketiOS • Google Play Store: aka.ms/LensRocketAndroid • iOS source code: aka.ms/LensRocketiOSsource • Android source code: aka.ms/LensRocketAndroidsource • More: chrisrisner.com • @ChrisRisner
Data • Azure SQL database by default • Many other options • Alternatively, use blob storage, table storage, SQL in a VM, or Oracle in a VM through the azure module for node.js or even on-prem SQL Server through Service Bus Relay • .NET runtime provides additional flexibility • Full control over your data in all scenarios SQL Server On-Prem SQL Server in a VM Mongo DB Azure SQL db Azure Table Storage Azure Blob Storage
Please leave this area blank to allow for picture in picture recording Data in LensRocket • SQL database tables for • AccountData • Friends • Messages • RocketFile • UserPreferences • Blob Storage for • Storing Rocket image files • Connect w/ SAS URL from Mobile Services then send a POST to blob storage
“Table” API Base Table API URL http://Mobileservice.azure-mobile.net/tables/* OData CRUD endpoints
Custom API • Node.js Express Controllers • Full control over HTTP • GET, POST, PUT, PATCH, DELETE • Mobile Services takes care of Auth, basic Authz, push, monitoring
Please leave this area blank to allow for picture in picture recording Custom APIs in LensRocket • Custom APIs for • AcceptFriendRequest • GetRocketForRecipient • Login • Register • RequestFriend • SaveUsername • SendRocketToFriends
Mobile Services .NET backend • ASP.NET WebAPI based • Custom API Regular ApiController • Table API XXXTableController • Helpful ODATA CRUD abstractions over various data backends • Transparent data access • Built-in auth, authz, push, monitoring, etc. • Client SDKs work with Mobile Services Node and .NET backends • We run, manage, and monitor your Mobile Service
Source Control and Deployment Mobile Services (git repository) TFS or GitHub (git repository) Local git repository
Automation npm install azure-cli --g azure mobile create | delete | list | show azure mobile restart azure mobile config list | get | set azure mobile table | data azure mobile script | api //use source control instead azure mobile job
Unit testing Node.js: var mock = require(“zumock”); //inspired by mocha .NET: NUnit, MSTest, etc Local F5, local debugging
Add version to your client calls - (void)handleRequest:(NSURLRequest *)request next:(MSFilterNextBlock)next response:(MSFilterResponseBlock)response { MSFilterResponseBlockwrappedResponse = ^(NSHTTPURLResponse *innerResponse, NSData *data, NSError *error) { response(innerResponse, data, error); }; // add additional versioning information to the querystring for versioning purposes NSString *append = [NSStringstringWithFormat:@"build=%@&version=%@", self.build, self.version]; NSURL *url = nil; NSRange range = [request.URL.absoluteStringrangeOfString:@"?"]; if (range.length > 0) { url = [NSURL URLWithString:[NSStringstringWithFormat:@"%@&%@&p=iOS", request.URL.absoluteString, append]]; } else { url = [NSURL URLWithString:[NSStringstringWithFormat:@"%@?%@&p=iOS", request.URL.absoluteString, append]]; } NSMutableURLRequest *newRequest = [request mutableCopy]; newRequest.URL = url; next(newRequest, wrappedResponse); }
Add version to your client calls public static MobileServiceClientMobileService = new MobileServiceClient( "https://<your subdomain>.azure-mobile.net/", "<your app key>", new VersionHandler() ); using System; using System.Net.Http; using System.Threading.Tasks; namespace WindowsStore { public class VersionHandler : DelegatingHandler { protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, System.Threading.CancellationTokencancellationToken) { request.RequestUri = new Uri(request.RequestUri.AbsoluteUri.ToString() + "?version=v2"); return base.SendAsync(request, cancellationToken); } } }
Support multiple client versions in your scripts function insert(item, user, request) { if (request.parameters.build < 2.0) { item.description = 'Not entered'; } request.execute({ success : function() { if (request.parameters.build < 2.0) { delete item.description; } request.respond(); } }); }
Mobile Push Notifications 101 • Register device handle at app launch • Client app contacts Platform Notification Service (PNS) • App updates handle in backend client app • Send Notification • App backend sends notification to PNS • PNS pushes the notification to the app on the device Platform Notification Service • Maintain device handles • Delete expired handles when PNS rejects them App back-end
Push Notification Challenges While there are significant benefits to using push notifications in a mobile app, rolling your own push infrastructure is extremely difficult in terms of implementing a system capable of: • Cross-Platform Push Notifications Each push service (APNS for iOS, GCM for Android, WNS for Windows, etc.) has different protocols (e.g., HTTP vs. TCP, xml payload vs. JSON payload) • Targeting on the server-side based on interest and location Segmenting users based on interest tags and routing only the most relevant content to each segment • Personalizing notifications on the client-side based on language, currency, device, etc. Each device displays notifications differently • High-Volume with Low Latency Limited by the capability of each VM so need to spin up scores of VMs and shard your application in order to serve a large user base • Maintaining and accurate device handle registry Adding registrations upon installation, updating tags, pruning upon rejection from push notification service (uninstall)
Azure Push Notifications One-time set up Create a Notification Hub Register The client app retrieves its current handle from the PNS. Client app (or app backend) registers the handle with Notification Hub Send Notification The app back-end sends a message to the Notification Hub. Notification Hub pushes it to the PNS Android app iOS app Windows 8.x app Notification Hub App back-end WNS APNs MPNS GCM
Mobile Services + Notification Hubs Mobile Services now with Notification Hubs built-in • Cross-Platform Push Notifications • Instant broadcast to segments of your audience, or individual pushes to logical users • Personalization and localization • High-Volume with Low Latency • Device handles and PNS feedback is managed for you
Please leave this area blank to allow for picture in picture recording Cross-Platform Push in LensRocket • Sending Push when • New Rocket arrives • New friend request received var payload ='{ "message" : "You\'ve received a new rocket!", "collapse_key" : "NEWROCKET" }'; notificationHubService.send(newMessage.toUserId, payload, • function(error, outcome) { • console.log('issue sending push'); • console.log('error: ', error); • console.log('outcome: ',outcome); • });
Please leave this area blank to allow for picture in picture recording Azure Store • Azure Store launched at //Build (Oct 2012). Currently in preview state. • makes it easy for Azure users to find, buy, and manage third-party services which complement and extend the Azure experience. • Add third-party services just as you would add a virtual machine or website. • Purchase using the same payment instrument as your Azure subscription. • Subscription management within Azure portal. • Single sign-on to third-party portal for service specific management tasks.
Mobile Store Partners aka.ms/SendGridMobile aka.ms/NewRelicMobile aka.ms/PusherMobile
Tips for Actually Publishing to the Store • Dev/Test Instance • Switch to using prod keys and info incl APNS cert, GCM API key • Make sure the permissions are as locked down as possible/access as restricted as possible • Turn off dynamic schema • Verify parameters, checking userIDs on all methods. • Authorization needs to be done in app code • Put in perf metrics (New Relic) • Put in usage metrics (Google) • Don’t put demo in the description • Have all the right assets • Get out of free mode • Auto-Scale
Mobile at //build • Building Cross-Platform Line of Business Apps with Mobile Services • Friday 4/4 12:30 – 1:30 PST • Donna Malayeri, Chris Risner • @lindydonna, @ChrisRisner • Mobile Push Notifications to Any Client with Azure Notification Hubs • Wednesday 4/2 5:30 – 6:30 PST • Elio Damaggio • @ElioDamaggio • Powerful mobile apps with Mobile Services and ASP.NET Web API • Thursday 4/3 5:30 – 6:30 PST • Kirill Gavrylyuk, Yavor Georgiev • @KirillG_MSFT, @theyavor • All videos will be available on Channel9
Mobile Services Resources Windows Azure Mobile Services Overview, Tutorials and Resourceshttp://www.windowsazure.com/en-us/develop/mobile/ Collection of Helpful Tutorials and Resources http://aka.ms/CommonWAMS Learn/Channel 9http://channel9.msdn.com/Series/Windows-Azure-Mobile-Services SDKs on GitHub https://github.com/WindowsAzure/azure-mobile-services/ REST API Reference http://msdn.microsoft.com/en-us/library/windowsazure/jj710108.aspx Windows Azure Pricinghttps://www.windowsazure.com/en-us/pricing/calculator/ UserVoice for Feature Requests http://feedback.windowsazure.com/forums/216254-mobile-services Microsoft Azure Certified Traininghttp://www.microsoft.com/learning/en/us/training/azure.aspx
Notification Hubs Resources Windows Azure Mobile Services Overview, Tutorials and Resources Azure Documentation Center MSDN Documenation Android (tutorial) iOS (tutorial) Windows Store (tutorial) Windows Phone (tutorial) Learn/Channel 9Introduction | iOS | Windows Store | Tags and Templates REST API Reference http://msdn.microsoft.com/en-us/library/windowsazure/jj710108.aspx Windows Azure Pricinghttp://www.windowsazure.com/en-us/pricing/details/notification-hubs/ Microsoft Azure Certified Traininghttp://www.microsoft.com/learning/en/us/training/azure.aspx