Cross platform development with azure mobile services


Published on

Cross platform development with azure mobile services

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Cross platform development with azure mobile services

  1. 1. Cross platform development with Azure Mobile Services Ibon Landa Plain Concepts
  2. 2.  
  3. 3. Mobile Platforms iOS Objective C Xcode Windows Phone C#/Visual Basic/F# Visual Studio Android Java Eclipse IntelliJ
  4. 4. What is Mobile Services?
  5. 5. The REST API Action HTTP Verb URL Suffix Create POST /TodoItem Read GET /TodoItem?$filter=id%3D42 Update PATCH /TodoItem/id Delete DELETE /TodoItem/id*
  6. 6. Mobile Services Tiers General Availability 99.9% Free Standard Premium Usage Restrictions Up to 10 services, Up to 500 Active Devices* N/A N/A API Calls 500K (per subscription) 1.5M (per unit) 15M (per unit) Scale N/A Up to 6 Standard units Up to 10 Enterprise units Scheduled Jobs Limited Included Included SQL Database (required) 20MB Included, Standard rates apply for more capacity 20MB Included, Standard rates apply for more capacity 20MB Included, Standard rates apply for more capacity
  7. 7. 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
  8. 8. Registration at app launch 1. Client app contacts Platform Notification Service, to retrieve current channel (e.g. ChannelURIs, device tokens, registrationIds) 2. App updates handle in back-end Sending Notification 1. App back-end send notification to PNS 2. PNS pushes the notification to the app on the device Maintenance 1. Delete expired handles when PNS rejects them Push notification lifecycle Platform Notification Service App back-end
  9. 9. Platform dependency Different communication protocols to PNS’ (e.g. HTTP vs TCP, xml payload vs json payload) Different presentation formats and capabilities (tiles vs toasts vs badges) Routing PNS’ 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 Scale App back-end has to store current handles for each device  high storage and VM costs Broadcast to millions of devices with low latency requires parallelization (DB ad VM) Challenges of push notifications
  10. 10. One-time set up 1. Create a Notification Hub Register 1. 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 Notification 1. The app back-end sends a message to the Notification Hub 2. Notification Hub pushes it to the PNS’ Using Notification Hubs APNsWNS Notification Hub App back-end iOS app Windows app MPNS GCM ADM
  11. 11. X-plat: from any back-end to any mobile platform Backend can be on-prem or in the cloud, .NET/Node/Java/PHP/Node/anything. Support Windows Phone/Windows/iOS/Android and (as of today) Kindle Fire. No need to store device information in the app back-end Notification Hub maintains the registry of devices and the associations to users/interest groups Routing and interest groups Target individual users and large interest groups using tags Personalization and localization Keep your back-end free of presentation concerns like localization and user preferences using templates Broadcast at scale, multicast, unicast Push notifications to millions of devices (across platforms) with a single call Telemetry Advantages of using Notification Hubs
  12. 12. Bing (news, finance, sports, …) Sochi 2014 Case studies 10s 3+ <2 100s 3+ 150+
  13. 13. Register Send Some snippets await [hub registerNativeWithDeviceToken:deviceToken tags:nil completion:^(NSError* error) { … }]; hub.register(regid); var toast = @“<notification payload>"; hub.SendWindowsNativeNotificationAsync(toast); hubService.wns.sendToastText01(null, { text1: 'Hello from Node!' }, function (error) { … } );
  14. 14. Tags as interest groups 1. Client app can register with a set of tags 2. Tags are simple strings (no pre-provisioning is required) 3. App back-end can target all clients with the same tag You can use tags also for Multiple type of interest groups, e.g. Follow bands: tag “followband:Beatles” Follow users: tag “followuser:Alice” Tag devices with a user id Tags Notification Hub App back-end Tag:”Beatles”Tag:”Wailers” Tag:”Beatles”
  15. 15. Register Some snippets await new string[] {"myTag", "myOtherTag"} [hub registerNativeWithDeviceToken:deviceToken tags:@[@"myTag", @"myOtherTag"] completion: ^(NSError* error) { … }]; hub.register(regid, "myTag“, "myOtherTag");
  16. 16. Notification Hubs is not a storage system Maintain an authoritative store for your tags In the device Every platform provides apps a way to store user information locally or in the cloud E.g. Roaming settings, iCloud In your app back-end Usually stored by user Try not to replicate device information Register methods always overwrite tags Each time you update the channel, overwrite all the tags “How do I read tags from my hub?”
  17. 17. Registration Client apps can register with a platform specific template, e.g. Windows tablet registers with Windows Store ToastText01 template iPhone with the Apple JSON template: { aps: {alert: “$(message)”}} Send notification App back-end sends a platform independent message: {message: “Hello!”} Notes Multiple templates can be specified for each device Each template can have a different set of tags Using templates for multi-platform push Notification Hub App back-end <toast> <visual> <binding template="ToastText01"> <text id="1">$(message)</text> </binding> </visual> </toast> { aps: { alert: “$(message)” } } { message: “Hello!” } Hello! Hello!
  18. 18. Registration Client apps can register with personalized templates, e.g. Windows tablet wants to receive news in English iPhone wants Italian Send notification App back-end sends a message including both languages: {news_en: “Hello!”, news_it: “Ciao!”} Template Expressions Templates support a simple expression language: E.g. {‘Elio, ’+$(friend)+’ added you to ’+$(groupName)} Using templates for localization Notification Hub App back-end <toast> <visual> <binding template="ToastText01"> <text id="1">$(news_en)</text> </binding> </visual> </toast> { aps: { alert: “$(news_it)” } } { news_en: “Hello!”, news_it: “Ciao!” } Hello! Ciao!
  19. 19. Thanks!