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

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

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