SlideShare a Scribd company logo
1 of 53
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.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();
}
See results on Windows 8 app
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();
}
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();

}
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 = 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();
});
}
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 string Text { get; set; }
[JsonProperty(PropertyName = "complete")]
public bool Complete { get; set; }
public string Platfrom { get; set; }
}
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);
}
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 notification
1.
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();
}
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();
}
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.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
});
});
Creating scheduler job
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“
});
}
}
});
}
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
minimize test cost
Activate your Windows Azure MSDN
benefit at no additional charge

aka.ms/msdnsubs
cr

More Related Content

What's hot

Vb database connections
Vb database connectionsVb database connections
Vb database connections
Tharsikan
 

What's hot (9)

The Ring programming language version 1.9 book - Part 82 of 210
The Ring programming language version 1.9 book - Part 82 of 210The Ring programming language version 1.9 book - Part 82 of 210
The Ring programming language version 1.9 book - Part 82 of 210
 
Leture5 exercise onactivities
Leture5 exercise onactivitiesLeture5 exercise onactivities
Leture5 exercise onactivities
 
XCUITest for iOS App Testing and how to test with Xcode
XCUITest for iOS App Testing and how to test with XcodeXCUITest for iOS App Testing and how to test with Xcode
XCUITest for iOS App Testing and how to test with Xcode
 
Coded ui - lesson 3 - case study - calculator
Coded ui - lesson 3 - case study - calculatorCoded ui - lesson 3 - case study - calculator
Coded ui - lesson 3 - case study - calculator
 
WAC Widget Upload Process
WAC Widget Upload ProcessWAC Widget Upload Process
WAC Widget Upload Process
 
Test script
Test scriptTest script
Test script
 
The Ring programming language version 1.5.1 book - Part 67 of 180
The Ring programming language version 1.5.1 book - Part 67 of 180The Ring programming language version 1.5.1 book - Part 67 of 180
The Ring programming language version 1.5.1 book - Part 67 of 180
 
Vb database connections
Vb database connectionsVb database connections
Vb database connections
 
Android ui layouts ,cntls,webservices examples codes
Android ui layouts ,cntls,webservices examples codesAndroid ui layouts ,cntls,webservices examples codes
Android ui layouts ,cntls,webservices examples codes
 

Viewers also liked

Viewers also liked (11)

Tuga - SAP and Azure, Better togheter
Tuga - SAP and Azure, Better togheterTuga - SAP and Azure, Better togheter
Tuga - SAP and Azure, Better togheter
 
SAP and Azure better together (Glenn Colpaert @TUGA IT 2016)
SAP and Azure better together (Glenn Colpaert @TUGA IT 2016)SAP and Azure better together (Glenn Colpaert @TUGA IT 2016)
SAP and Azure better together (Glenn Colpaert @TUGA IT 2016)
 
Azure Resource Manager Templates
Azure Resource Manager TemplatesAzure Resource Manager Templates
Azure Resource Manager Templates
 
Migrating sap wft_case_study_final (1)
Migrating sap wft_case_study_final (1)Migrating sap wft_case_study_final (1)
Migrating sap wft_case_study_final (1)
 
SAP powered by Microsoft Azure: A match made in the cloud
SAP powered by Microsoft Azure: A match made in the cloud SAP powered by Microsoft Azure: A match made in the cloud
SAP powered by Microsoft Azure: A match made in the cloud
 
SAP on Azure. Use Cases and Benefits
SAP on Azure. Use Cases and BenefitsSAP on Azure. Use Cases and Benefits
SAP on Azure. Use Cases and Benefits
 
Leverage the Power of SAP HANA with Microsoft Azure Cloud Migration
Leverage the Power of SAP HANA with Microsoft Azure Cloud MigrationLeverage the Power of SAP HANA with Microsoft Azure Cloud Migration
Leverage the Power of SAP HANA with Microsoft Azure Cloud Migration
 
SAP Basics
SAP BasicsSAP Basics
SAP Basics
 
What is SAP| SAP Introduction | Overview of SAP
What is SAP| SAP Introduction | Overview of SAPWhat is SAP| SAP Introduction | Overview of SAP
What is SAP| SAP Introduction | Overview of SAP
 
SAP INTRO
SAP INTROSAP INTRO
SAP INTRO
 
SAP for Beginners
SAP for BeginnersSAP for Beginners
SAP for Beginners
 

Similar to CloudBrew: Windows Azure Mobile Services - Next stage

Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 series
openbala
 

Similar to CloudBrew: Windows Azure Mobile Services - Next stage (20)

GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
 
Windows Phone 7 Unleashed Session 2
Windows Phone 7 Unleashed Session 2Windows Phone 7 Unleashed Session 2
Windows Phone 7 Unleashed Session 2
 
AI: Mobile Apps That Understands Your Intention When You Typed
AI: Mobile Apps That Understands Your Intention When You TypedAI: Mobile Apps That Understands Your Intention When You Typed
AI: Mobile Apps That Understands Your Intention When You Typed
 
Mobile for SharePoint with Windows Phone
Mobile for SharePoint with Windows PhoneMobile for SharePoint with Windows Phone
Mobile for SharePoint with Windows Phone
 
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter LehtoJavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
JavaCro'14 - Building interactive web applications with Vaadin – Peter Lehto
 
Creating an Uber Clone - Part XIII - Transcript.pdf
Creating an Uber Clone - Part XIII - Transcript.pdfCreating an Uber Clone - Part XIII - Transcript.pdf
Creating an Uber Clone - Part XIII - Transcript.pdf
 
Android+ax+app+wcf
Android+ax+app+wcfAndroid+ax+app+wcf
Android+ax+app+wcf
 
Xamarin devdays 2017 - PT - connected apps
Xamarin devdays 2017 - PT - connected appsXamarin devdays 2017 - PT - connected apps
Xamarin devdays 2017 - PT - connected apps
 
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on AndroidMobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
Mobile 2.0 Open Ideas WorkShop: Building Social Media Enabled Apps on Android
 
Android ax app wcf
Android ax app wcfAndroid ax app wcf
Android ax app wcf
 
Windows Azure: Connecting the Dots for a Mobile Workforce
Windows Azure: Connecting the Dots for a Mobile WorkforceWindows Azure: Connecting the Dots for a Mobile Workforce
Windows Azure: Connecting the Dots for a Mobile Workforce
 
Windows Azure Mobile Services
Windows Azure Mobile ServicesWindows Azure Mobile Services
Windows Azure Mobile Services
 
Introduction to Firebase [Google I/O Extended Bangkok 2016]
Introduction to Firebase [Google I/O Extended Bangkok 2016]Introduction to Firebase [Google I/O Extended Bangkok 2016]
Introduction to Firebase [Google I/O Extended Bangkok 2016]
 
WinAppDriver - Windows Store Apps Test Automation
WinAppDriver - Windows Store Apps Test AutomationWinAppDriver - Windows Store Apps Test Automation
WinAppDriver - Windows Store Apps Test Automation
 
Cómo tener analíticas en tu app y no volverte loco
Cómo tener analíticas en tu app y no volverte locoCómo tener analíticas en tu app y no volverte loco
Cómo tener analíticas en tu app y no volverte loco
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
 
20150812 4시간만에 따라해보는 windows 10 앱 개발
20150812  4시간만에 따라해보는 windows 10 앱 개발20150812  4시간만에 따라해보는 windows 10 앱 개발
20150812 4시간만에 따라해보는 windows 10 앱 개발
 
Bot builder v4 HOL
Bot builder v4 HOLBot builder v4 HOL
Bot builder v4 HOL
 
SRV421 Deep Dive with AWS Mobile Services
SRV421 Deep Dive with AWS Mobile ServicesSRV421 Deep Dive with AWS Mobile Services
SRV421 Deep Dive with AWS Mobile Services
 
Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 series
 

More from Teemu Tapanila

More from Teemu Tapanila (7)

Connecting your IoT devices to azure - Techorama 2019
Connecting your IoT devices to azure - Techorama 2019Connecting your IoT devices to azure - Techorama 2019
Connecting your IoT devices to azure - Techorama 2019
 
Deploy with confidence and speed to Microsoft azure using visual studio team ...
Deploy with confidence and speed to Microsoft azure using visual studio team ...Deploy with confidence and speed to Microsoft azure using visual studio team ...
Deploy with confidence and speed to Microsoft azure using visual studio team ...
 
Building analytics with event grid
Building analytics with event gridBuilding analytics with event grid
Building analytics with event grid
 
CloudBrew 2016 - Building IoT solution with Service Fabric
CloudBrew 2016 - Building IoT solution with Service FabricCloudBrew 2016 - Building IoT solution with Service Fabric
CloudBrew 2016 - Building IoT solution with Service Fabric
 
TechDays 2013: Creating backend with windows azure mobile services
TechDays 2013: Creating backend with windows azure mobile servicesTechDays 2013: Creating backend with windows azure mobile services
TechDays 2013: Creating backend with windows azure mobile services
 
AppCampus Overview 19.9
AppCampus Overview 19.9AppCampus Overview 19.9
AppCampus Overview 19.9
 
AppCampus overview
AppCampus overviewAppCampus overview
AppCampus overview
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

CloudBrew: Windows Azure Mobile Services - Next stage

  • 1.
  • 3. What is Mobile Services?
  • 4.
  • 5. Authentication out of the box • • • • Microsoft Account Twitter login Google login Facebook login
  • 11. Windows 8 sample application
  • 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. See results on Windows 8 app
  • 14.
  • 15. 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(); }
  • 16. 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(); }
  • 17.
  • 19. Read operation function read(query, user, request) { request.execute(); }
  • 20. 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(); }); }
  • 21.
  • 22. Major features of data handling • Dynamic schema • Windows Azure SQL Database
  • 23. 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; } }
  • 24. 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); }
  • 26. Data at SQL explorer
  • 27.
  • 33. Notification is done! App start and send channel to mobile service 2. Mobile service saves that into database and sends notification 1.
  • 34. 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(); }
  • 35. 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(); }
  • 36.
  • 39. Clone your git repository
  • 43. 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 }); });
  • 44.
  • 46. 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“ }); } } }); }
  • 47.
  • 49. Log on Visual Studio
  • 50.
  • 51. What is Mobile Services?
  • 52.
  • 53. 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