Thank you, sponsors!
What is Mobile Services?
Authentication out of the box
•
•

•
•

Microsoft Account
Twitter login
Google login
Facebook login
Developers.facebook.com
Setup facebook
Setup Mobile Services
Create Windows 8 project
Set table access level
Windows 8 sample application
Enable authenication
private MobileServiceUser user;
private async Task Authenticate()
{

user = await App.MobileService.L...
See results on Windows 8 app
Enable authenication
private MobileServiceUser user;
private async Task Authenticate()
{

user = await App.MobileService.L...
Authentication with groups on client
private FacebookSessionClient FacebookSessionClient = new FacebookSessionClient("1434...
CRUD
•

Create
• Read
• Update
• Delete
Read operation
function read(query, user, request) {
request.execute();
}
Read operation with filtering

function read(query, user, request) {
var identities = user.getIdentities();
var req = requ...
Major features of data handling
•

Dynamic schema
• Windows Azure SQL Database
Changing table model
public class TodoItem
{
public string Id { get; set; }
[JsonProperty(PropertyName = "text")]
public s...
Changing handling logic
private async void UpdateCheckedTodoItem(TodoItem item)
{
if (item.Platfrom == null)
{
item.Platfr...
Data at portal
Data at SQL explorer
Notifications
•

Windows Phone
• Android
• iPhone
• Windows 8
Adding notifications to Windows 8
Visual Studio wizard
Reserve application name
Choose used mobile service
Notification is done!
App start and send channel to mobile service
2. Mobile service saves that into database and
sends no...
Client implementation 2.0
public async static void UploadChannel(MobileServiceUser user)
{
var channel = await
PushNotific...
TodoItem Insert
function insert(item, user, request) {
var identities = user.getIdentities();
var fbUserId = identities.fa...
Enable from portal
Git repository
Clone your git repository
Folder structure
NPM install
Sendgrid
Sending email
var req = require('request');
var fbAccessToken = identities.facebook.accessToken;
var url = 'https://graph....
Creating scheduler job
BrewCloud
function BrewCloud() {
var td = tables.getTable("TodoItem");
td.where({ complete: false }).read({
success: funct...
Log on portal
Log on Visual Studio
What is Mobile Services?
The Cloud for
Modern Business

Grab your benefit

aka.ms/azuretry

Deploy fast in the
cloud, scale
elastically and
minimiz...
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
CloudBrew: Windows Azure Mobile Services - Next stage
Upcoming SlideShare
Loading in...5
×

CloudBrew: Windows Azure Mobile Services - Next stage

651

Published on

Have a need for backend but don't have people to build it for you? Windows Azure Mobile Service is service to build backend service quickly with all of the often needed features. In this session we will start from basics and continue to next level from there and look how you can start to use the service for advanced scenarios!

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
651
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

CloudBrew: Windows Azure Mobile Services - Next stage

  1. 1. Thank you, sponsors!
  2. 2. What is Mobile Services?
  3. 3. Authentication out of the box • • • • Microsoft Account Twitter login Google login Facebook login
  4. 4. Developers.facebook.com
  5. 5. Setup facebook
  6. 6. Setup Mobile Services
  7. 7. Create Windows 8 project
  8. 8. Set table access level
  9. 9. Windows 8 sample application
  10. 10. Enable authenication private MobileServiceUser user; private async Task Authenticate() { user = await App.MobileService.LoginAsync(MobileServiceAuthenticationProvider.Facebook); var message = string.Format("You are now logged in - {0}", user.UserId); var dialog = new MessageDialog(message); dialog.Commands.Add(new UICommand("OK")); await dialog.ShowAsync(); } protected override async void OnNavigatedTo(NavigationEventArgs e) { await Authenticate(); RefreshTodoItems(); }
  11. 11. See results on Windows 8 app
  12. 12. Enable authenication private MobileServiceUser user; private async Task Authenticate() { user = await App.MobileService.LoginAsync(MobileServiceAuthenticationProvider.Facebook); var message = string.Format("You are now logged in - {0}", user.UserId); var dialog = new MessageDialog(message); dialog.Commands.Add(new UICommand("OK")); await dialog.ShowAsync(); } protected override async void OnNavigatedTo(NavigationEventArgs e) { await Authenticate(); RefreshTodoItems(); }
  13. 13. Authentication with groups on client private FacebookSessionClient FacebookSessionClient = new FacebookSessionClient("1434104456805487"); private FacebookSession fbSession; private MobileServiceUser user; private async Task Authenticate() { fbSession = await FacebookSessionClient.LoginAsync("user_groups,user_likes,email"); var client = new FacebookClient(fbSession.AccessToken); var token = JObject.FromObject(new { access_token = fbSession.AccessToken}); user = await App.MobileService.LoginAsync(MobileServiceAuthenticationProvider.Facebook, token); } protected override async void OnNavigatedTo(NavigationEventArgs e) { await Authenticate(); RefreshTodoItems(); }
  14. 14. CRUD • Create • Read • Update • Delete
  15. 15. Read operation function read(query, user, request) { request.execute(); }
  16. 16. Read operation with filtering function read(query, user, request) { var identities = user.getIdentities(); var req = require('request'); var fbAccessToken = identities.facebook.accessToken; var url = 'https://graph.facebook.com/me?fields=groups.fields(id)&access_token=' + fbAccessToken; req(url, function (err, resp, body) { var userData = JSON.parse(body); var groups = userData.groups.data; for(var i=0;i<groups.length;i++){ if (groups[i].id == "304013539633881") { request.execute(); return; } } query.take(2); request.execute(); }); }
  17. 17. Major features of data handling • Dynamic schema • Windows Azure SQL Database
  18. 18. Changing table model public class TodoItem { public string Id { get; set; } [JsonProperty(PropertyName = "text")] public string Text { get; set; } [JsonProperty(PropertyName = "complete")] public bool Complete { get; set; } public string Platfrom { get; set; } }
  19. 19. Changing handling logic private async void UpdateCheckedTodoItem(TodoItem item) { if (item.Platfrom == null) { item.Platfrom = "Windows 8"; } await todoTable.UpdateAsync(item); items.Remove(item); } private void ButtonSave_Click(object sender, RoutedEventArgs e) { var todoItem = new TodoItem { Text = TextInput.Text, Platfrom = "Windows 8" }; InsertTodoItem(todoItem); }
  20. 20. Data at portal
  21. 21. Data at SQL explorer
  22. 22. Notifications • Windows Phone • Android • iPhone • Windows 8
  23. 23. Adding notifications to Windows 8
  24. 24. Visual Studio wizard
  25. 25. Reserve application name
  26. 26. Choose used mobile service
  27. 27. Notification is done! App start and send channel to mobile service 2. Mobile service saves that into database and sends notification 1.
  28. 28. Client implementation 2.0 public async static void UploadChannel(MobileServiceUser user) { var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); var token = HardwareIdentification.GetPackageSpecificToken(null); string installationId = CryptographicBuffer.EncodeToBase64String(token.Id); var ch = new Jobject { {"channelUri", channel.Uri}, {"installationId", installationId}, {"userId", user.UserId.Substring(9)} }; await App.MobileService.GetTable("channels").InsertAsync(ch); } private MobileServiceUser user; protected override async void OnNavigatedTo(NavigationEventArgs e) { await Authenticate(); cloudbrewtapanila.cloudbrewtapanilaPush.UploadChannel(user); RefreshTodoItems(); }
  29. 29. TodoItem Insert function insert(item, user, request) { var identities = user.getIdentities(); var fbUserId = identities.facebook.userId; var ct = tables.getTable("channels"); ct.where({ userId: fbUserId }).read({ success: function (results) { if (results.length > 0) { sendNotifications(results[0].channelUri,item); } } }); function sendNotifications(uri,todoItem) { push.wns.sendToastText01(uri, { text1: "You have just inserted new todo " + todoItem.text }, { success: function (pushResponse) { console.log("Sent push:", pushResponse); } }); } request.execute(); }
  30. 30. Enable from portal
  31. 31. Git repository
  32. 32. Clone your git repository
  33. 33. Folder structure
  34. 34. NPM install
  35. 35. Sendgrid
  36. 36. Sending email var req = require('request'); var fbAccessToken = identities.facebook.accessToken; var url = 'https://graph.facebook.com/me?fields=email&access_token=' + fbAccessToken; req(url, function (err, resp, body) { var userData = JSON.parse(body); var userEmail = userData.email; var sendgrid = require('sendgrid')("TapanilaCloudBrew", "password"); sendgrid.send({ to: userEmail, from: 'teemu@tapanila.net', subject: ‘New todoitem added', text: ‘You added new todoitem ‘ + todoItem.text }); });
  37. 37. Creating scheduler job
  38. 38. BrewCloud function BrewCloud() { var td = tables.getTable("TodoItem"); td.where({ complete: false }).read({ success: function (results) { if (results.length > 0) { var sendgrid = require('sendgrid')("TapanilaCloudBrew", "password"); sendgrid.send({ to: "teemu@tapanila.net", from: 'teemu@tapanila.net', subject: 'Status of brewing cloud', text: 'There is ' + results.length + " items left“ }); } } }); }
  39. 39. Log on portal
  40. 40. Log on Visual Studio
  41. 41. What is Mobile Services?
  42. 42. The Cloud for Modern Business Grab your benefit aka.ms/azuretry Deploy fast in the cloud, scale elastically and minimize test cost Activate your Windows Azure MSDN benefit at no additional charge aka.ms/msdnsubs cr
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×