<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Azure Mobile Services Archives - Blog IT</title>
	<atom:link href="https://blogit.create.pt/category/cloud/microsoft-azure/azure-mobile-services/feed/" rel="self" type="application/rss+xml" />
	<link>https://blogit.create.pt/category/cloud/microsoft-azure/azure-mobile-services/</link>
	<description>Create IT blogger community</description>
	<lastBuildDate>Thu, 10 Jan 2019 12:46:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Add scheduled adaptive live tiles to your UWP app</title>
		<link>https://blogit.create.pt/ricardocaldeira/2016/07/12/add-scheduled-adaptive-live-tiles-to-your-uwp-app/</link>
					<comments>https://blogit.create.pt/ricardocaldeira/2016/07/12/add-scheduled-adaptive-live-tiles-to-your-uwp-app/#comments</comments>
		
		<dc:creator><![CDATA[Ricardo Caldeira]]></dc:creator>
		<pubDate>Tue, 12 Jul 2016 14:33:20 +0000</pubDate>
				<category><![CDATA[Azure Scheduled Jobs]]></category>
		<category><![CDATA[Azure Mobile Services]]></category>
		<category><![CDATA[UWP]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Microsoft Azure]]></category>
		<category><![CDATA[Adaptive Live Tiles]]></category>
		<guid isPermaLink="false">http://blogit.create.pt/ricardocaldeira/?p=911</guid>

					<description><![CDATA[<p>Today I&#8217;ll help you add some bling to your UWP apps (and maybe something useful) with scheduled live tiles using the built-in features on the W10 SDK and some Azure help &#8211; although any cloud storage provider should do fine. I&#8217;ll divide this into the &#8220;backend stuff&#8221;, where we&#8217;ll generate our tile templates, and the &#8220;client [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/ricardocaldeira/2016/07/12/add-scheduled-adaptive-live-tiles-to-your-uwp-app/">Add scheduled adaptive live tiles to your UWP app</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today I&#8217;ll help you add some bling to your UWP apps (and maybe something useful) with scheduled live tiles using the built-in features on the W10 SDK and some Azure help &#8211; although any cloud storage provider should do fine. I&#8217;ll divide this into the &#8220;backend stuff&#8221;, where we&#8217;ll generate our tile templates, and the &#8220;client stuff&#8221;, where your app will consume the tile notifications.</p>
<p>It goes without saying that you need Visual Studio (VS) and the W10 SDK, which I assume you have installed.</p>
<p>I&#8217;ll provide some examples from my pet project <a href="https://www.microsoft.com/en-US/store/apps/Pocketnow-WP/9NBLGGH3G3RZ" target="_blank">Pocketnow WP</a>, so don&#8217;t worry if you see some references to it 🙂</p>
<h1>1. The backend stuff</h1>
<p>Here I&#8217;ll make use of some Azure features, so it&#8217;s best that you have a working subscription. What we want to achieve is a set of XML files on blob storage with the tile templates. You can use any other means to achieve this, as long as the end result remains the same.</p>
<p>This particular setup is free in Azure given that the tile generation is simple and doesn&#8217;t usually involve much data IO or CPU.</p>
<p>First off, please a create a mobile service on the management portal, or use an existing one if your app already makes use of it. I won&#8217;t go over the details, so I assume you already have some experience on the subject. In the end, I want you to be on the &#8220;Get started&#8221; page, ready to download your starter project (in C#). If you already have a mobile services project in your solution, use that one and skip this step.</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/07/dashboard.png"><img fetchpriority="high" decoding="async" src="http://blogit-create.com/wp-content/uploads/2016/07/dashboard.png" alt="dashboard" width="729" height="652" class="aligncenter size-full wp-image-1471" srcset="https://blogit.create.pt/wp-content/uploads/2016/07/dashboard.png 729w, https://blogit.create.pt/wp-content/uploads/2016/07/dashboard-300x268.png 300w, https://blogit.create.pt/wp-content/uploads/2016/07/dashboard-696x622.png 696w, https://blogit.create.pt/wp-content/uploads/2016/07/dashboard-470x420.png 470w" sizes="(max-width: 729px) 100vw, 729px" /></a></p>
<p>After opening the project in VS, you&#8217;ll have the default mobile service project structure with lots of unnecessary things (for us). We just want to focus on the ScheduledJobs folder where we will put our brilliant new job to generate the templates:</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/02/mobile5.png" rel="attachment wp-att-951"><img decoding="async" class="size-medium wp-image-951 aligncenter" src="http://blogit-create.com/wp-content/uploads/2016/02/mobile5-285x300.png" alt="mobile5" width="285" height="300" /></a></p>
<p>You could use the default &#8220;SampleJob.cs&#8221; as the starting point, but let&#8217;s add a new one to keep it clean:</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/02/mobile6.png" rel="attachment wp-att-981"><img decoding="async" class="aligncenter size-full wp-image-981" src="http://blogit-create.com/wp-content/uploads/2016/02/mobile6.png" alt="mobile6" width="694" height="904" /></a></p>
<p>Give it a fancy name ending with &#8220;Job&#8221; (this is important!)</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/02/mobile7.png" rel="attachment wp-att-991"><img decoding="async" class="aligncenter size-full wp-image-991" src="http://blogit-create.com/wp-content/uploads/2016/02/mobile7.png" alt="mobile7" width="954" height="660" srcset="https://blogit.create.pt/wp-content/uploads/2016/02/mobile7.png 954w, https://blogit.create.pt/wp-content/uploads/2016/02/mobile7-300x208.png 300w, https://blogit.create.pt/wp-content/uploads/2016/02/mobile7-768x531.png 768w, https://blogit.create.pt/wp-content/uploads/2016/02/mobile7-100x70.png 100w, https://blogit.create.pt/wp-content/uploads/2016/02/mobile7-218x150.png 218w, https://blogit.create.pt/wp-content/uploads/2016/02/mobile7-696x482.png 696w, https://blogit.create.pt/wp-content/uploads/2016/02/mobile7-607x420.png 607w" sizes="(max-width: 954px) 100vw, 954px" /></a></p>
<p>You&#8217;ll end up with an empty class like this:</p>
<pre class="brush: csharp; title: ; notranslate">using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace pocketnoww10Service.ScheduledJobs
{
    public class LovelyLiveTileGeneratorJob
    {
    
    }
}</pre>
<p>Next, we need to make it runnable by Azure, so make it inherit from ScheduledJob and add the ExecuteAsync method:</p>
<pre class="brush: csharp; title: ; notranslate">public class LovelyLiveTileGeneratorJob : ScheduledJob
{
    public async override Task ExecuteAsync()
    {
        Services.Log.Info(&quot;Hello from scheduled job! The time is precisely &quot; + DateTime.Now.ToUniversalTime());
    }
}</pre>
<p>You should now be able to publish the mobile service to Azure and test it, but let&#8217;s add the rest of the code before we try it.</p>
<p>The next step is to generate the templates as described in the <a href="https://msdn.microsoft.com/en-us/library/windows/apps/mt590880.aspx" target="_blank">SDK reference</a>. I&#8217;ll produce a string version of the XML step-by-step, but you can use the code provided in the MSDN reference. I&#8217;m adding a new UpdateLiveTileFile method which will generate the tile template code and write it to a container in Azure blob storage. In this next bit of code I assume that I have a model for my stories which I want to appear in my users&#8217; live tiles, entering the method as a list. Inside I&#8217;ll iterate them and build template strings:</p>
<p>&nbsp;</p>
<pre class="brush: csharp; title: ; notranslate">private async Task UpdateLiveTileFile(IEnumerable&lt;StoryModel&gt; stories)
{
    foreach (StoryModel story in stories)
    {
		string xmlContent = 
			&quot;&lt;tile&gt;&quot; +
			&quot;  &lt;visual branding=\&quot;nameAndLogo\&quot;&gt;&quot; +
			&quot;    &lt;binding template=\&quot;TileMedium\&quot; branding=\&quot;name\&quot;&gt;&quot; +
			&quot;      &lt;text hint-style=\&quot;body\&quot; hint-wrap=\&quot;true\&quot;&gt;&quot; + System.Security.SecurityElement.Escape(story.Title) + &quot;&lt;/text&gt;&quot; +
			&quot;     &lt;image placement=\&quot;background\&quot; src=\&quot;&quot; + System.Security.SecurityElement.Escape(story.PictureSource) + &quot;\&quot; hint-overlay=\&quot;40\&quot; /&gt;&quot; +
			&quot;    &lt;/binding&gt;&quot; +
			&quot;    &lt;binding template=\&quot;TileWide\&quot;&gt;&quot; +
			&quot;      &lt;group&gt;&quot; +
			&quot;        &lt;subgroup hint-weight=\&quot;33\&quot;&gt;&quot; +
			&quot;          &lt;image placement=\&quot;inline\&quot; src=\&quot;&quot; + System.Security.SecurityElement.Escape(story.AuthorPictureSource) + &quot;\&quot; hint-crop=\&quot;circle\&quot; /&gt;&quot; +
			&quot;        &lt;/subgroup&gt;&quot; +
			&quot;        &lt;subgroup&gt;&quot; +
			&quot;      &lt;text hint-style=\&quot;body\&quot; hint-wrap=\&quot;true\&quot;&gt;&quot; + System.Security.SecurityElement.Escape(story.Title) + &quot;&lt;/text&gt;    &quot; +
			&quot;      &lt;/subgroup&gt;&quot; +
			&quot;      &lt;/group&gt;&quot; +
			&quot;     &lt;image placement=\&quot;background\&quot; src=\&quot;&quot; + System.Security.SecurityElement.Escape(story.PictureSource) + &quot;\&quot; hint-overlay=\&quot;40\&quot; /&gt;&quot; +
			&quot;    &lt;/binding&gt;&quot; +
			&quot;    &lt;binding template=\&quot;TileLarge\&quot;&gt;&quot; +
			&quot;      &lt;group&gt;&quot; +
			&quot;        &lt;subgroup hint-weight=\&quot;33\&quot;&gt;&quot; +
			&quot;          &lt;image placement=\&quot;inline\&quot; src=\&quot;&quot; + System.Security.SecurityElement.Escape(story.AuthorPictureSource) + &quot;\&quot; hint-crop=\&quot;circle\&quot; /&gt;&quot; +
			&quot;        &lt;/subgroup&gt;&quot; +
			&quot;        &lt;subgroup&gt;&quot; +
			&quot;        &lt;text hint-style=\&quot;caption\&quot; hint-wrap=\&quot;true\&quot;&gt;&quot; + System.Security.SecurityElement.Escape(story.Title) + &quot;&lt;/text&gt;    &quot; +
			&quot;        &lt;/subgroup&gt;&quot; +
			&quot;      &lt;/group&gt;&quot; +
			&quot;      &lt;image placement=\&quot;inline\&quot; src=\&quot;&quot; + System.Security.SecurityElement.Escape(story.PictureSource) + &quot;\&quot; /&gt;      &quot; +
			&quot;    &lt;/binding&gt;&quot; +
			&quot;  &lt;/visual&gt;&quot; +
			&quot;&lt;/tile&gt;&quot;;
    }
}</pre>
<p>To protect your eyes, here&#8217;s a generated template using this code. You can see 3 binding sections, each for a different tile size (in this case Medium, Wide and Large). Again, check the reference for a description of the options:</p>
<pre class="brush: xml; title: ; notranslate">&lt;tile&gt;
  &lt;visual branding=&quot;nameAndLogo&quot;&gt;
    &lt;binding template=&quot;TileMedium&quot; branding=&quot;name&quot;&gt;
      &lt;text hint-style=&quot;body&quot; hint-wrap=&quot;true&quot;&gt;Samsung Galaxy Tab S2 9.7 treated to Marshmallow makeover in Europe&lt;/text&gt;
     &lt;image placement=&quot;background&quot; src=&quot;http://pocketnow.com/images/300/190/1454330272/2016/04/Galaxy-Tab-S2-9.7-1.jpg&quot; hint-overlay=&quot;40&quot; /&gt;
    &lt;/binding&gt;
    &lt;binding template=&quot;TileWide&quot;&gt;
      &lt;group&gt;
        &lt;subgroup hint-weight=&quot;33&quot;&gt;
          &lt;image placement=&quot;inline&quot; src=&quot;http://pocketnow.com/images/50/50/1454330272/userphoto/72.jpg&quot; hint-crop=&quot;circle&quot; /&gt;
        &lt;/subgroup&gt;
        &lt;subgroup&gt;
      &lt;text hint-style=&quot;body&quot; hint-wrap=&quot;true&quot;&gt;Samsung Galaxy Tab S2 9.7 treated to Marshmallow makeover in Europe&lt;/text&gt;    
      &lt;/subgroup&gt;
      &lt;/group&gt;
     &lt;image placement=&quot;background&quot; src=&quot;http://pocketnow.com/images/300/190/1454330272/2016/04/Galaxy-Tab-S2-9.7-1.jpg&quot; hint-overlay=&quot;40&quot; /&gt;
    &lt;/binding&gt;
    &lt;binding template=&quot;TileLarge&quot;&gt;
      &lt;group&gt;
        &lt;subgroup hint-weight=&quot;33&quot;&gt;
          &lt;image placement=&quot;inline&quot; src=&quot;http://pocketnow.com/images/50/50/1454330272/userphoto/72.jpg&quot; hint-crop=&quot;circle&quot; /&gt;
        &lt;/subgroup&gt;
        &lt;subgroup&gt;
        &lt;text hint-style=&quot;caption&quot; hint-wrap=&quot;true&quot;&gt;Samsung Galaxy Tab S2 9.7 treated to Marshmallow makeover in Europe&lt;/text&gt;    
        &lt;/subgroup&gt;
      &lt;/group&gt;
      &lt;image placement=&quot;inline&quot; src=&quot;http://pocketnow.com/images/300/190/1454330272/2016/04/Galaxy-Tab-S2-9.7-1.jpg&quot; /&gt;      
    &lt;/binding&gt;
  &lt;/visual&gt;
&lt;/tile&gt;</pre>
<p>Now that we have our generated templates, we need to store them on Azure (or your equivalent). If you already have a storage account you can use it and skip the first step, but please create a new container:</p>
<p>First, create a storage account:<br />
<a href="http://blogit-create.com/wp-content/uploads/2016/02/storage1.png" rel="attachment wp-att-1041"><img decoding="async" class="aligncenter size-full wp-image-1041" src="http://blogit-create.com/wp-content/uploads/2016/02/storage1.png" alt="storage1" width="862" height="412" /></a></p>
<p>Then create a container:</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/02/storage2.png" rel="attachment wp-att-1051"><img decoding="async" class="aligncenter size-full wp-image-1051" src="http://blogit-create.com/wp-content/uploads/2016/02/storage2.png" alt="storage2" width="612" height="292" srcset="https://blogit.create.pt/wp-content/uploads/2016/02/storage2.png 612w, https://blogit.create.pt/wp-content/uploads/2016/02/storage2-300x143.png 300w" sizes="(max-width: 612px) 100vw, 612px" /></a></p>
<p>Now we need to get a connection string to connect the mobile service to this storage account. To do this go to the dashboard and check the access keys in the bottom app bar, then take note of your storage account name (if you already forgot it) and copy the primary access key:</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/02/storage3.png" rel="attachment wp-att-1061"><img decoding="async" class="aligncenter size-full wp-image-1061" src="http://blogit-create.com/wp-content/uploads/2016/02/storage3.png" alt="storage3" width="715" height="437" /></a></p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/02/storage4.png" rel="attachment wp-att-1062"><img decoding="async" class="aligncenter size-full wp-image-1062" src="http://blogit-create.com/wp-content/uploads/2016/02/storage4.png" alt="storage4" width="543" height="445" srcset="https://blogit.create.pt/wp-content/uploads/2016/02/storage4.png 543w, https://blogit.create.pt/wp-content/uploads/2016/02/storage4-300x246.png 300w, https://blogit.create.pt/wp-content/uploads/2016/02/storage4-512x420.png 512w" sizes="(max-width: 543px) 100vw, 543px" /></a></p>
<p>We can now add a new connection string to our web.config to connect to this storage account, so open it (should be on the project root) and add a new connection called &#8220;StorageConnectionString&#8221; inside the connectionStrings tag using the access key you copied. It should look like this:</p>
<pre class="brush: xml; title: ; notranslate">&lt;connectionStrings&gt;
    &lt;add name=&quot;MS_TableConnectionString&quot; connectionString=&quot;XXXX&quot; providerName=&quot;System.Data.SqlClient&quot; /&gt;
    &lt;add name=&quot;MS_NotificationHubconnectionString&quot; connectionString=&quot;XXXX&quot; /&gt;
    &lt;add name=&quot;StorageConnectionString&quot; connectionString=&quot;DefaultEndpointsProtocol=https;AccountName=&lt;YOUR_STORAGE_ACCOUNT&gt;;AccountKey=&lt;YOUR_PRIMARY_ACCESS_KEY&gt;&quot; /&gt;
&lt;/connectionStrings&gt;</pre>
<p>Now we need to connect to the container using this connection string. In the beginning of UpdateLiveTileFile method add some initialization code (check the inline comments):</p>
<pre class="brush: csharp; title: ; notranslate">// Get the connection string
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings&#x5B;&quot;StorageConnectionString&quot;].ConnectionString);

// Get a blob client
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

// Create or get an existing container (use a nice name for this, AND NOT HARDCODED)
CloudBlobContainer container = blobClient.GetContainerReference(&quot;LovelyLiveTileGeneratorContainerName&quot;);
bool result = await container.CreateIfNotExistsAsync();

// Set the permissions on the container to public so that client apps can access it
// This means you shouldn't use this container for anything else
await container.SetPermissionsAsync(new BlobContainerPermissions
{
    PublicAccess = BlobContainerPublicAccessType.Blob
});</pre>
<p>Finally, prepare our generation loop to write to the blob for each tile with a <strong>different number each time.</strong> In the end the loop should look like this.</p>
<pre class="brush: csharp; title: ; notranslate">// Start an iterator to be appended to the file name
int i = stories.Count() - 1;
foreach (StoryModel story in stories)
{
    #region Template generation code
    ...
    #endregion

    // Get a file reference -&gt; CHANGE THE NAME OF THE FILE!
    CloudBlockBlob fileBlob = container.GetBlockBlobReference(string.Format(&quot;LovelyLiveTileFile-{0}.xml&quot;, i));

    // And write to the file
    await fileBlob.UploadTextAsync(xmlContent);
    i--;
}</pre>
<hr />
<p>Our next step is to publish the mobile service to Azure. To ease the process you can download a publish profile from your mobile service dashboard:</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/02/mobile8.png" rel="attachment wp-att-1101"><img decoding="async" class="aligncenter size-full wp-image-1101" src="http://blogit-create.com/wp-content/uploads/2016/02/mobile8.png" alt="mobile8" width="728" height="457" /></a></p>
<p>Then go to your project and hit Publish from the context menu:</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/02/mobile9.png" rel="attachment wp-att-1111"><img decoding="async" class="aligncenter size-full wp-image-1111" src="http://blogit-create.com/wp-content/uploads/2016/02/mobile9.png" alt="mobile9" width="566" height="344" srcset="https://blogit.create.pt/wp-content/uploads/2016/02/mobile9.png 566w, https://blogit.create.pt/wp-content/uploads/2016/02/mobile9-300x182.png 300w" sizes="(max-width: 566px) 100vw, 566px" /></a></p>
<p>Now browse to the publish profile you just downloaded:</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/02/mobile10.png" rel="attachment wp-att-1141"><img decoding="async" class="aligncenter size-full wp-image-1141" src="http://blogit-create.com/wp-content/uploads/2016/02/mobile10.png" alt="mobile10" width="716" height="553" /></a></p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/02/mobile11.png" rel="attachment wp-att-1121"><img decoding="async" class="aligncenter size-full wp-image-1121" src="http://blogit-create.com/wp-content/uploads/2016/02/mobile11.png" alt="mobile11" width="718" height="565" /></a></p>
<p>Then press OK till you reach the last page, where you press Publish:</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/02/mobile12.png" rel="attachment wp-att-1131"><img decoding="async" class="aligncenter size-full wp-image-1131" src="http://blogit-create.com/wp-content/uploads/2016/02/mobile12.png" alt="mobile12" width="716" height="564" srcset="https://blogit.create.pt/wp-content/uploads/2016/02/mobile12.png 716w, https://blogit.create.pt/wp-content/uploads/2016/02/mobile12-300x236.png 300w, https://blogit.create.pt/wp-content/uploads/2016/02/mobile12-696x548.png 696w, https://blogit.create.pt/wp-content/uploads/2016/02/mobile12-533x420.png 533w" sizes="(max-width: 716px) 100vw, 716px" /></a></p>
<p>You should now run the job once to ensure the files are being generated. To achieve this, go to the mobile service page on the azure management portal and access the &#8220;Scheduler&#8221; tab. Here you should open the job you just published:</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/07/scheduler.png"><img decoding="async" class="aligncenter wp-image-1381" src="http://blogit-create.com/wp-content/uploads/2016/07/scheduler.png" alt="scheduler" width="1024" height="153" /></a>Then click &#8220;Run once&#8221;</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/07/run_once.png"><img decoding="async" class="aligncenter size-full wp-image-1371" src="http://blogit-create.com/wp-content/uploads/2016/07/run_once.png" alt="run_once" width="565" height="570" srcset="https://blogit.create.pt/wp-content/uploads/2016/07/run_once.png 565w, https://blogit.create.pt/wp-content/uploads/2016/07/run_once-150x150.png 150w, https://blogit.create.pt/wp-content/uploads/2016/07/run_once-297x300.png 297w, https://blogit.create.pt/wp-content/uploads/2016/07/run_once-416x420.png 416w" sizes="(max-width: 565px) 100vw, 565px" /></a></p>
<p>If all went well (no reason it shouldn&#8217;t have), if you access your blob container URL directly from a browser you should be presented with the generated tile templates:</p>
<p><a href="http://blogit-create.com/wp-content/uploads/2016/07/blob.png"><img decoding="async" class="wp-image-1391 aligncenter" src="http://blogit-create.com/wp-content/uploads/2016/07/blob.png" alt="blob" width="1000" height="440" srcset="https://blogit.create.pt/wp-content/uploads/2016/07/blob.png 1201w, https://blogit.create.pt/wp-content/uploads/2016/07/blob-300x132.png 300w, https://blogit.create.pt/wp-content/uploads/2016/07/blob-768x339.png 768w, https://blogit.create.pt/wp-content/uploads/2016/07/blob-1024x452.png 1024w, https://blogit.create.pt/wp-content/uploads/2016/07/blob-696x307.png 696w, https://blogit.create.pt/wp-content/uploads/2016/07/blob-1068x471.png 1068w, https://blogit.create.pt/wp-content/uploads/2016/07/blob-952x420.png 952w" sizes="(max-width: 1000px) 100vw, 1000px" /></a></p>
<p>That&#8217;s it for our first part! Now comes the easier bit &#8211; consume the files we&#8217;ve just generated.</p>
<hr />
<h1>2. The client stuff</h1>
<p>It&#8217;s considerably easy to consume the generated tile template files from a UWP app. I usually put my code on the App.xaml.cs, but it can go anywhere. Here&#8217;s a summary of the steps you need to do:</p>
<ol>
<li>Instantiate a TileUpdater</li>
<li>Set a list of URIs to be polled</li>
<li>Enable queued notifications</li>
<li>Set the polling frequency</li>
<li>Start polling</li>
<li>Profit</li>
</ol>
<p>This translates to very simple code that can run at startup or on demand (if you tie it to your settings page).</p>
<p>First off, add a new method on your App.xaml.cs (or wherever you want a method to subscribe your app to tile updates):</p>
<pre class="brush: csharp; title: ; notranslate">public static void SubscribeToTileNotifications()
{
	TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
}</pre>
<p>Now then, we need a way to turn tile updates on and off. I usually do this by writing a bool on my roaming settings (usually on a settings page which I won&#8217;t include), but you can use whichever method you prefer. So, let&#8217;s assume that somewhere in your app there&#8217;s a process that writes to the tag &#8220;LIVE_TILE_ONOFF&#8221; on the roaming settings and add some logic to the subscribe method you just created:</p>
<pre class="brush: csharp; title: ; notranslate">ApplicationDataContainer appSettings = ApplicationData.Current.RoamingSettings;
if (appSettings.Values.Keys.Contains(&quot;LIVE_TILE_ONOFF&quot;)
    &amp;&amp; (bool)appSettings.Values&#x5B;&quot;LIVE_TILE_ONOFF&quot;])
{
   // subscription code
}
else
{
   // unsubscription code
}</pre>
<p>Next, we need to construct a list with URLs pointing to the templates we are creating on the blob container. A simple loop should do (don&#8217;t forget to set your blob container URL on TILE_UPDATE_URL), so add it under the subscription code comment:</p>
<pre class="brush: csharp; title: ; notranslate">List&lt;Uri&gt; tileUpdateUris = new List&lt;Uri&gt;();
string TILE_UPDATE_URL = &quot;https://&lt;YOUR_STORAGE_ACCOUNT&gt;.blob.core.windows.net/LovelyLiveTileGeneratorContainerName/LovelyLiveTileFile-{0}.xml&quot;;
int TILE_UPDATE_SIZE = 5;
for (int i = 0; i &lt; TILE_UPDATE_SIZE; i++)
{
	tileUpdateUris.Add(new Uri(string.Format(TILE_UPDATE_URL, i)));
}</pre>
<p>We can now ask the tile updater to subscribe to notifications. There are several options for the update recurrence, but I&#8217;ll stick with an hardcoded hourly update.</p>
<pre class="brush: csharp; title: ; notranslate">tileUpdater.EnableNotificationQueue(true);
tileUpdater.StartPeriodicUpdateBatch(tileUpdateUris, PeriodicUpdateRecurrence.Hour);</pre>
<p>Finally, you should also add some code to unsubscribe from notifications (by user command), so add this under the unsubscription code comment on the else block:</p>
<pre class="brush: csharp; title: ; notranslate">tileUpdater.Clear();
tileUpdater.EnableNotificationQueue(false);
tileUpdater.StopPeriodicUpdate();</pre>
<p>In the end you should end up with something like this:</p>
<pre class="brush: csharp; title: ; notranslate">public static void SubscribeToTileNotifications()
{
	TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

	ApplicationDataContainer appSettings = ApplicationData.Current.RoamingSettings;
	if (appSettings.Values.Keys.Contains(&quot;LIVE_TILE_ONOFF&quot;)
        &amp;&amp; (bool)appSettings.Values&#x5B;&quot;LIVE_TILE_ONOFF&quot;])
	{
		List&lt;Uri&gt; tileUpdateUris = new List&lt;Uri&gt;();
		string TILE_UPDATE_URL = &quot;https://&lt;YOUR_STORAGE_ACCOUNT&gt;.blob.core.windows.net/LovelyLiveTileGeneratorContainerName/LovelyLiveTileFile-{0}.xml&quot;;
		int TILE_UPDATE_SIZE = 5;
		for (int i = 0; i &lt; TILE_UPDATE_SIZE; i++)
		{
			tileUpdateUris.Add(new Uri(string.Format(TILE_UPDATE_URL, i)));
		}

		tileUpdater.EnableNotificationQueue(true);
		tileUpdater.StartPeriodicUpdateBatch(tileUpdateUris, PeriodicUpdateRecurrence.Hour);
	}
	else
	{
		tileUpdater.Clear();
		tileUpdater.EnableNotificationQueue(false);
		tileUpdater.StopPeriodicUpdate();
	}
}</pre>
<p>All that&#8217;s left to do is call your new method SubscribeToTileNotifications from somewhere in your app and you&#8217;re done, your tiles will come to life!</p>
<p>The post <a href="https://blogit.create.pt/ricardocaldeira/2016/07/12/add-scheduled-adaptive-live-tiles-to-your-uwp-app/">Add scheduled adaptive live tiles to your UWP app</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/ricardocaldeira/2016/07/12/add-scheduled-adaptive-live-tiles-to-your-uwp-app/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Azure Mobile Services News &#8211; Issue#4</title>
		<link>https://blogit.create.pt/ricardocosta/2014/11/07/azure-mobile-services-news-issue4/</link>
					<comments>https://blogit.create.pt/ricardocosta/2014/11/07/azure-mobile-services-news-issue4/#respond</comments>
		
		<dc:creator><![CDATA[Ricardo Costa]]></dc:creator>
		<pubDate>Fri, 07 Nov 2014 11:25:29 +0000</pubDate>
				<category><![CDATA[Azure Mobile Services]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Microsoft Azure]]></category>
		<guid isPermaLink="false">http://blogit.create.pt/ricardocosta/?p=791</guid>

					<description><![CDATA[<p>Logging in with Google, Microsoft and Facebook SDKs to Azure Mobile Services &#8220;One of the values that Azure Mobile Services provides is an easy way to implement authentication for mobile applications, via a very simple API – call a login function (or equivalent) on the client object in any of the supported platforms, and your [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/ricardocosta/2014/11/07/azure-mobile-services-news-issue4/">Azure Mobile Services News &#8211; Issue#4</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><a href="http://azure.microsoft.com/blog/2014/10/27/logging-in-with-google-microsoft-and-facebook-sdks-to-azure-mobile-services/" target="_blank"><strong>Logging in with Google, Microsoft and Facebook SDKs to Azure Mobile Services</strong></a></p>
<p><em>&#8220;One of the values that Azure Mobile Services provides is an easy way to implement authentication for mobile applications, via a very simple API – call a login function (or equivalent) on the client object in any of the supported platforms, and your user gets presented with a simple web-based interface that allows them to log in to your mobile service. This is what we call a server-side authentication flow, where the service guides the client to the provider (via redirections in the web page) and then back to itself.&#8221;</em></p>
<hr />
<p>&nbsp;</p>
<p><a href="http://azure.microsoft.com/blog/2014/10/17/azure-service-bus-namespacetype-default-value-change/" target="_blank"><strong>Azure Service Bus – ‘NamespaceType’ default value change</strong></a></p>
<p><em>&#8220;Recently we announced that we are splitting the user experience between Service Bus and Notification Hubs to enable a better experience for Notification Hubs.&#8221;</em></p>
<hr />
<p>&nbsp;</p>
<p><strong><a href="http://azure.microsoft.com/blog/2014/10/16/rich-push-with-notification-hubs-in-ios-8/" target="_blank">Rich Push with Notification Hubs in iOS 8</a></strong></p>
<p><em>&#8220;In order to engage users with instant rich content, applications often push notifications beyond just plain text. These notifications can contain urls, images, sounds, and more. &#8220;</em></p>
<hr />
<p>&nbsp;</p>
<p><a href="http://azure.microsoft.com/blog/2014/10/10/better-support-for-paging-with-table-storage-in-azure-mobile-services-net-backend/" target="_blank"><strong>Better support for paging with Table Storage in Azure Mobile Services .NET backend</strong></a></p>
<p><em>&#8220;When we released the .NET backend for Azure Mobile Services, we provided support to store data in Azure Table Storage and MongoDB databases (in addition to the SQL Azure storage which has been used since the first version of the service).&#8221;</em></p>
<p>&nbsp;</p>
<p>The post <a href="https://blogit.create.pt/ricardocosta/2014/11/07/azure-mobile-services-news-issue4/">Azure Mobile Services News &#8211; Issue#4</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/ricardocosta/2014/11/07/azure-mobile-services-news-issue4/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
