Menu

Why your Company Should Invest in a Mobile Application

mobile_apps

The customers in today’s world are on the move and they’re using mobile application platforms to get there. Whether they use mobile phones, tablets, or other mobile devices they have all the information they need. That’s why mobile apps are so much important in today’s market.

Mobile Applications can increase your Brand Awareness, Customer Loyalty, and Annual Revenue

You will find below 5 reasons of why your company should invest in a mobile application.

People Spend More Time using Mobile Apps

Mobile users spend 89 % of the time using mobile apps. It also leaves 11 % for mobile web browsing. It’s prove why many businesses have mobile portal / responsive websites, but still they don’t consider mobile apps as a channel for their customers.

If your business don’t have a mobile application, you reducing your chances to reach more people to interact with your company using smartphones.

Mobile applications make it easier to your customers to navigate and reach to the content. This make them convenient and responsive to your offers.

Note: Expected 4.4 billion mobile users will use mobile apps by 2017.

Mobile Applications increase Brand Awareness, Customer Loyalty, Annual Revenue and build a strong relationships with the customers.

When users start to make the effort to download an application, it means they are really care and they’re already engaged with your brand. You can use this engagement and develop a real relationship and brand loyalty through your application. You can use it as a direct communication channel to deliver your message and your offering to them.

Include an easy way for customers to offer feedback on the app, your business, and their experiences interacting with your firm.

Also you have to include the direct messaging communication channel (push notifications) to deliver a free direct message to them using the mobile application to engage them more and gain the attention/interaction of this customers. this will allow you to gain more sales.

Listening to people’s about what they likes and dislikes gives a valuable insight into what you’re doing right and what you need to do better.

Note: Use these engaged consumers for research about new products ,developments and offers.

Apps Generate New Leads and Increase Sales

Most businesses think of apps as a great way to connect with their existing customers. but it’s a wrong though, people always downloading new apps every second and it’s a lead-generation potential.

If your app offers users real value, people will want to use it, even if they were previously unfamiliar with your brand.

A well-designed app can introduce a the user to your company/brand and turn someone unfamiliar with your firm into a loyal fan.

Through providing a channel to users to interact with your brand you will gain a huge opportunity to collect your users data through ex. registration.

Also via providing a full journey through your application, your customers will be able to engage more ,this engagement will lead them to be loyal and this will lead them to be a potential no they will be your next customer.

Mobile Apps Deliver Quicker Customer Support

No matter how cheerful your business/application may be, your customers don’t want to wait to know info’s. Instead, they’d rather get answers and information as quickly and efficiently as possible.

your application have to enable your business to provide a channel to your customers to support and answers the FAQs.

The result is a better experience for your customers and lower call volumes for your customer support staff.

It Gives You an Edge Over Your Competition

As we we discussed above, thousand of businesses don’t have a mobile app. If you do, you’re offering potential customers and loyal fans. Something that your competitors don’t have or offer.

Give yourself and your business a new edge a new channel to offer it to your customers.

Creating an app is a great way to appear more tech savvy and give your company the competitive edge it’s been looking for.

Make your business appeal to an ever-connected to your loyal and potential consumers.

This is just a 5 reasons for Why your Company Should Invest in a Mobile Application, but there is more reasons that make you invest and start create an application.

But keep in your mind

Mobile Applications can increase your Brand Awareness, Customer Loyalty, and Annual Revenue.

Advertisements

Grow Your Windows App Revenue – Choose the Best Business Model

Double your revenue, Double your Joy

Grow

Thousand of developers develop a hundred of apps, but don’t know that he can double his/her revenue through this platform.

In this series of blogs I want to talk about the  Model to increase revenue opportunity and it’s steps.

Choose the Best Business Model

  • Publish your App
  • Market your App
  • Optimize your App

Capture

In today blog i will talk about how to choose your business model that match your app and can double your revenue.

To choose your best business model you have to know the different option the windows phone platform support.

1) Choose a business model – windows Phone support the below three options as a business model to get revenue from your app
– Paid
– In-App Purchase
– Mobile Ads

Paid Business Model: this Business model is used for apps that are leaders in their type of app.

let us see first the Paid apps best practices from using trials.

use Trial  94% of top 50 paid apps use it

Capture

Continue reading

It’s here! The Microsoft Ignite Session Catalog

It’s here! The Microsoft Ignite Session Catalog

image002

Hundreds of newly released sessions to spark your Ignite planning

The Microsoft Ignite Session Catalog is here! Be sure to take a look at the hundreds of sessions covering cloud infrastructure and management, big data and analytics, productivity, unified communications, operating systems, and mobile devices at the biggest enterprise technology event of the year! You’ll find sessions that provide deep technical detail on specific products, as well sessions that provide strategy, guidance and best practices on security and topics including deployment, operations and usage. We will be adding more sessions and labs in the coming weeks, so please check back often for updates.

Get more out of Ignite with a Pre-Day Session

For an additional investment of $500, Pre-Day Sessions on Sunday, May 3, 9:00 am – 5:00 pm. offer a unique opportunity to extend your learning experience with a full day of focused training the day before the conference opens. These sessions are designed to provide you with a deep knowledge base and skills that you can apply as soon as you’re back in the office. You’ll be able to tap into the knowledge and insights of the people who, in many cases, literally wrote the book on their subject.

Network and network, then network some more

There is something special about the connections you make at events. That’s why we’re making it easy for you to find and connect with others interested in similar topics. There will be meet ups in lounges; fire-starter and birds-of-a-feather community-led sessions in theaters; regional, industry and technology-focused meal-time mashups; and after hour networking events with Microsoft tech and business leaders to add to your agenda to unwind, kick back, and truly enjoy the scene. You can talk tech all day and night.

Mark your calendars for #IgniteJam on Twitter

On February 3rd at 9:00 am PT, we’ll have the whole event team and lots of speakers ready to chat with you on Twitter. We’ll be ready to answer your questions about the event and hear what you’re excited about in terms of community experiences and things to do in Chicago. Add the event to your calendar with this link.

To participate in this #IgniteJam

  1. Join us on Twitter (or for easier real-time participation join us on Twubs at:  http://twubs.com/ignitejam to participate (you’ll need to sign in, it’s free)
  2. Log in to Twitter at 9:00 AM PT on February 3rd
  3. Follow us on Twitter at @MS_Ignite
  4. Start tweeting and include #IgniteJam in your tweets!

Feeling fired up? See where technology is headed and meet who’s fueling it—at Ignite. Register today, and add a Pre-Day Session to your Ignite agenda.

Enterprises / Business Hub

business

Windows Phone has been always a great choice for consumers with its great set of features, and its level of customization, to simply make your Windows Phone unmistakably yours.

But Microsoft didn’t just focus on delighting the consumers. Microsoft also focused on meeting the needs of business. Features like Office, BitLocker, Native support for IRM, supporting Exchange server; ActiveSync; Sharepoint; Lync server & Company Hub, makes Windows Phone “The right choice for Business”.

In this post, we’ll talk about “Company Hub”, and how it enables enterprises to increase the productivity of their employees, by providing the right business apps and information right to their hands.

Company Hub, for Users (the Employees), is a one stop shop for work on the phone. Employees can see a list of business apps provided by the enterprise, and get all the information they need to be productive and stay up to date.

Company Hub, for the developers is simply a Windows Phone app which will use special tools (for signing and compiling) and set of APIs to list the business apps provided by the enterprise. Also, like any other Windows Phone app, developers can add more features and be creative. For example, the app can show the latest news and events about the company or even push the important news to the phone using Push Notifications to keep the employees updated.

business-site-apps-hub-896x240

Before creating the app, We need to get the following:

  1. Publisher ID, even though you will not publish the app to the store, you still need this ID to list the business apps installed on the phone. Also, it will be used to get the Enterprise Mobile Code Signing Certificate.
  2. Enterprise Mobile Code Signing Certificate, which will be used to get PFX certificate
  3. PFX certificate, which will be used to get Application Enrollment Token & Sign the business apps (including company hub)
  4. Application Enrollment Token, which will be used to enroll the phones to the enterprise (otherwise, the phones wont be able to install the business apps)

We will get through details of each one.

Getting a Publisher ID

To get the publisher ID you will need to sign up through Windows Phone Dev Center for a Company Account (NOT Individual/Student). Signing up will go through two steps; first complete the registration and paying the subscription feeds (costs now $99 per year). Second step is completing the Microsoft Account Validation Process.

image_thumb

Microsoft Account Validation Process helps to protect your company’s identity from being used without your knowledge, while also maintaining trust for the people buying your apps.

You will receive an email from Symantec (which is a Microsoft partner that works to validate the authenticity of the business registered in the Windows Phone Dev Center). In that email, Symantec will ask for more info to validate your account, and might also call you toe complete the process

Getting Enterprise Mobile Code Signing Certificate

After verifying your account, we need to get the Enterprise Mobile Code Signing Certificate. Go to the Enterprise Mobile Code Signing Certificate website, and Enter the Publisher ID and the email you used to sign up in the Dev Center. (This certificate costs now $299 per year).
Once you’re done, you will get the Enterprise Mobile Code Signing Certificate. Import this certificate into your computer.
image_thumb_15

Exporting PFX file

We will export the PFX certificate using the Enterprise Mobile Code Signing Certificate which was imported to the computer

To export the PFX certificate using the Certificates snap-in:

  1. Go to the Start menu and search for “run” and then type mmc to start the Microsoft Management Console.
  2. On the File menu, click Add/Remove Snap-in. The Add or Remove Snap-ins dialog box appears.

3. In Available snap-ins, click Certificates, and then click Add.

image_thumb_2

4. Select Computer account, and then click Next.

5. Select Local computer, and then click Finish.

6. If you have no more snap-ins to add to the console, click OK.

7. In the Microsoft Management Console, in the console tree, expand Certificates, and then expand Personal.

8. In the details pane, click the certificate you want to manage. Right click on the certificate, point to All Tasks, and then click Export. The Certificate Export Wizard appears. Click Next.

9. On the Export Private Key page, click Yes, export the private key. Click Next.

image_thumb_8

10. On the Export File Format page, select Personal Information Exchange – PKCS #12 (.PFX). Click Next.

11. On the Password page, type and confirm the password that is used to encrypt the private key. Click Next.

12. Follow the pages of the wizard to export the certificate in PFX format.

Creating Application Enrollment Token

To create the Application Enrollment  Token (AET), we will use the PFX certificate we created in the previous step. From the Windows Phone SDK, we will use the AETGenerator:
Start the VS2012 x86 Native Tools Command Prompt as an administrator.
image

Change the current directory to the directory where the PFX file is located.
Run the AETGenerator tool with the following command line. Be sure to replace the placeholder text in this command with appropriate values. replace the “key.pfx” with your own certificate name, & the P@ssw0rd with your password.
image_thumb_13

This command will generate AET files with different extensions. These files will be used to enroll the employees’ phones to the enterprise. If you have Windows Intune orSystem Center implemented, then the AET.aet will be used.

If the company doesn’t have Windows Intune or System Center, then the AET.aetx file will be used. You can simply send this file as an email attachment or host this file on some secure web server so employees can download it later to enroll their phones.

Precompile, sign and Distribute the business app

Before distributing the business apps (including the Company Hub), we need to do the following for each one:
Precompile any managed assemblies that are included in the XAP into native code. (MDILXAPCompile will be used)
Sign the XAP with the PFX file that is exported from the enterprise certificate (XapSignTool will be used)

Now instead of executing the commands MDILXAPCompile and XapSignTool manually, Microsoft provided a script to automate the whole process in one line using PowerShell :

You will have to provide three values:
The package file (XAP)
The PFX certificate file
The password

Now that your packages are precompiled and signed. you can host the packages in some secure web server. And list these apps inside your Company Hub app

Mobile Apps in your business

Mobile Apps in Your Business

The customers in today’s world are on the move and they’re using mobile application platforms to get there. Whether they use mobile phones, tablets, or other mobile devices they have all the information they need. That’s why mobile apps are so much important in today’s market.


You need to understand that mobile apps allow customers to have all your information at their fingertips. Also, it is important that your app works on multiple mobile application platforms. But for beginning, start with one platform.

No matter what your business is, a mobile app can help you get and retain customers., and that’s a fact. We all know that the first place customers go to search for a product or service is online. If your business is available online, and plus you have an app that users can download to their devices, your business will make really good impression. At a glance they will be able to see and open your app and purchase from your business.

Here are some of the biggest benefits of mobile apps for businesses. You can:

  • build loyalty
  • reinforce your brand
  • increase your visibility
  • increase your accessibility
  • increase sell-through
  • increase exposure across mobile devices
  • connect you with on-the-go consumers

There are more of course. These are just some of the biggest. As you can see, benefits can be huge.

Not only that your business will have benefits, but your customers as well. Here are some of the benefits of mobile apps for your customers. They can:

  • easy access to your inventory
  • get notifications of special events, launches, etc.
  • have one-touch access to your contact information
  • get directions to your location from wherever they are
  • make fast, seamless appointment scheduling

Until now, it should be really clear – the future of your business depends on your ability to get your business implanted on the phones of customers all around the world. You need to go mobile and be prepared to grow.

Important fact to note: Promotional email messages receive about a 4% read rate. PUSH notifications 97%.

Not only will your mobile app be a cool marketing tool, that will help get people returning to your website, but it will allow you to engage with your customers in a whole new way.

Finally:

Mobile Applications can increase your Brand Awareness, Customer Loyalty, and Annual Revenue. Ask me how (amr.khamise@linkdev.com).

announcing #Windows 10 الاعلان عن ويندوز 10

10401521_309989069204016_6584578891305394575_n

أهم ما جاء في مؤتمر مايكروسوفت للإعلان عن ويندوز 10 ‪#‎Windows10‬ والذي ينتظر إطلاقه رسميا في وقت متأخر من العام القادم 2015
1- مفيش ويندوز 9، كانوا عايزين يسموه ويندوز 1 بس للأسف ما ينفعش فسموه ويندوز 10
2- نظام واحد للأجهزة المختلفة سواء مكتبية أو محمولة أو لوحية
3- واجهة جديدة لمستخدم الجهاز المكتبي تتضمن شكلا جديدا لقائمة ابدأ يناسب استخدام الفأرة ولوحة المفاتيح
4- واجهة لاستخدام الجهاز اللوحي تتضمن شاشة ابدأ التي قدمت لأول مرة في ويندوز 8
5- الانتقال بين الواجهتين آلي حين يتعرف النظام على طبيعة أدوات الإدخال المستخدمة (لوحة مفاتيح وفأرة – قلم ولمس)
6- إمكانية استخدام المفاتيح المختصرة CTRL+V للصق النصوص في CMD
7- إطلاق برنامج Windows Insider Program بهدف تلقي الاقتراحات والدعم والمساعدة في تطوير النظام الجديد
8- تم عمل بيئة تطويرية جديدة تعمل عبر جميع بيئات الأجهزة المكتبية واللوحية والويب، مما يسهل الأمر على المطورين
9- سيتم الكشف عن المزيد بخصوص ويندوز 10 في مؤتمر Build الذي يعقد في منتصف العام القادم

Add App Bar in Windows 8.1 XAML Applications

IC671114

Windows 8.1 simplifies a lot the creation of AppBars. We no longer need to use buttons with a particular style, because now the built-in AppBarButton control is available. The following example shows the main characteristics of the new AppBar:

  <Page.BottomAppBar>
        <CommandBar>
            <CommandBar.PrimaryCommands>
                <!-- These commands appear on the right -->
                <AppBarButton Icon="Play" Label="Play"/>
                <AppBarSeparator />
                <AppBarButton Icon="Add" Label="Add item" />
            </CommandBar.PrimaryCommands>

            <CommandBar.SecondaryCommands>
                <!-- These commands appear on the left -->
                <AppBarButton Label="Edit">
                    <AppBarButton.Icon>
                        <SymbolIcon Symbol="Edit" />
                    </AppBarButton.Icon>
                </AppBarButton>
                <AppBarButton Label="Rss" Icon="Read">
                
                </AppBarButton>
                <AppBarButton Icon="Globe" Label="Website"></AppBarButton>
            </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.BottomAppBar>

As we can see, everything is simpler. Instead of Grid and StackPanel, we have a CommandBar object that exposes two properties, PrimaryCommands and SecondaryCommands, that respectively contain buttons that appear on the right and on the left of the bar: appbar The AppBar has one more important feature that helps us adhere to UI design guidelines. When screen size gets smaller, Windows 8.1 automatically drops margins and labels to make buttons fit the available space. If this isn’t sufficient, Secondary commands are dropped at all.

In the previous post, we talked about Menus and Flyouts. We can use them with AppBarButton too, because it inherits from Button:

   <AppBarButton Icon="Add" Label="Add item">
    <AppBarButton.Flyout>
        <Flyout>
            <StackPanel Width="406">
                <TextBlock Text="Insert the value and tap the Send button:" FontSize="16"
                   FontWeight="SemiLight" FontFamily="Segoe UI"
                   Margin="0,0,0,10"  />
                <TextBox x:Name="ValueTextBox" />
                <Button Content="Send" HorizontalAlignment="Right"
                    FontSize="16" Margin="0,10,0,0" />
            </StackPanel>
        </Flyout>
    </AppBarButton.Flyout>
</AppBarButton>

appbar2

With the appbar added we now dont need to add extra buttons on the UI thus giving more space to content. It helps users organise the tasks they are doing.

Similarly you can also add a top appbar.

  <Page.TopAppBar>
        <CommandBar>
            <CommandBar.PrimaryCommands>
                <!-- These commands appear on the right -->
                <AppBarButton Icon="Play" Label="Play"/>
                <AppBarSeparator />
                <AppBarButton Icon="Add" Label="Add item">
                    <AppBarButton.Flyout>
                        <Flyout>
                            <StackPanel Width="406">
                                <TextBlock Text="Insert the value and tap the Send button:" FontSize="16"
                   FontWeight="SemiLight" FontFamily="Segoe UI"
                   Margin="0,0,0,10"  />
                                <TextBox x:Name="ValueTextBox" />
                                <Button Content="Send" HorizontalAlignment="Right"
                    FontSize="16" Margin="0,10,0,0" />
                            </StackPanel>
                        </Flyout>
                    </AppBarButton.Flyout>
                </AppBarButton>
            </CommandBar.PrimaryCommands>

            <CommandBar.SecondaryCommands>
                <!-- These commands appear on the left -->
                <AppBarButton Label="Edit">
                    <AppBarButton.Icon>
                        <SymbolIcon Symbol="Edit" />
                    </AppBarButton.Icon>
                </AppBarButton>
                <AppBarButton Label="Rss" Icon="Read">

                </AppBarButton>
                <AppBarButton Icon="Globe" Label="Website"></AppBarButton>
            </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.TopAppBar>

You can find a list of all default icons here and you can add custom icons as well.

  <AppBarButton Label="Rss">
                        <AppBarButton.Icon>
                            <BitmapIcon UriSource="/Assets/appbar.rss.png" />
                        </AppBarButton.Icon>
                    </AppBarButton>

 

So have  fun and add app bar to your application

Portable Class Library for SQLite Windows 8.1

Microsoft Open Technologies has recently released a Portable Class Library for SQLite. Thanks to it, we can use SQLite in the same way in all the supported platforms.

As a prerequiste you need to have SQLite for Windows 8.1 and then add as a reference to your project. Because it is a native library, the “Any CPU” architecture is not supported, so we need to choose a specific target platform: Visual studio will reference the appropriate extension SDK version the the project compiles.

Adding Reference to the Project

Now we use NuGet to install the portable library to our project.

Portable Sqlite Library

Now everything is ready to start using the library. Suppose for example we want to create a database named data.db with a Users table:

using (var connection = new SQLiteConnection("data.db"))
{
    using (var statement = connection.Prepare(@"CREATE TABLE IF NOT EXISTS Users (
                                                ID INTEGER NOT NULL PRIMARY KEY,
                                                FirstName NVARCHAR(50),
                                                LastName NVARCHUAR(50));"))
    {
        statement.Step();
    }
}

At this moment, SQLite PCL supports only direct SQL commands (no LINQ provider). At line 3, we use the connection.Prepare method to define the DDL query we want to execute. Then, on line 8, with statement.Step, we send the query to the database engine, that immediately executes it.
Now lets insert some data into the table.

using (var statement = connection.Prepare(@"INSERT INTO Users (FirstName, LastName)
                                            VALUES(@firstName, @lastName);"))
{
    statement.Bind("@firstName", "Rahber");
    statement.Bind("@lastName", "Ashraf");

    // Inserts data.
    statement.Step();

    // Resets the statement, to that it can be used again (with different parameters).
    statement.Reset();
    statement.ClearBindings();

    statement.Bind("@firstName", "Some User first name");
    statement.Bind("@lastName", "Some user last name");

    // Inserts data.
    statement.Step();
}

Again, the Prepare method is used to define the SQL command. In this case, it is an INSERT in which we have defined two parameters, @firstName and @lastName. At line 4-5, we bind them to their actual values, using the Bind method. The Step command (line 8) finalizes the operation.

And to retrieve the data we use the following code.

using (var statement = connection.Prepare(@"SELECT * FROM Users ORDER BY FirstName;"))
{
    while (statement.Step() == SQLiteResult.ROW)
    {
        var id = (long)statement[0];
        var firstName = (string)statement[1];
        var lastName = (string)statement[2];
    }
}

To read the records returned by the query, we need to iterate through the rows, in a way that resembles the SqlDataReader.Read method.

In order to retrieve the actual values, we need to use the indexer operator on the statement object, specifying the column number. As this method gets a result of Object type, we need to cast it to the real type of the column. If we want to avoid this syntax, and instead prefer to use generics, we can define a simple extension method:

public static class SQLitePCLExtensions
{
    public static T GetValue(this ISQLiteStatement statement, int index)
    {
        return (T)statement[index];
    }
}
And Finally now you can use the library easy 

NFC to have a Skype call with Windows 8.1

Check this blog if you want to rich your application with the availability to have a skype call with your friends from your app just using your NFC

ProximityDevice has made life easier to publish content that can be received by other NFC readable devices.
We can publish a uri to tag, we can publish a http:// protocol and it will launch the web link in the browser. So we can publish the uri to skype call.

  1. privatevoidWriteSkypeTag(string skypeUsername)
  2. {
  3. var device =ProximityDevice.GetDefault();
  4. if(device !=null)
  5. {
  6. using(var writer =newDataWriter{UnicodeEncoding=UnicodeEncoding.Utf16LE})
  7. {
  8. // Prepare the message to be published.
  9. var uri =string.Format(“skype:{0}?call”, skypeUsername);
  10. writer.WriteString(uri);
  11. var buffer = writer.DetachBuffer();
  12.  
  13. // Publish the message. You must tap an NFC tag to your device to write
  14. // the content to it.
  15. device.PublishBinaryMessage(“WindowsUri:WriteTag”, buffer,
  16. async (sender, messageId)=&gt;
  17. {
  18. device.StopPublishingMessage(messageId);
  19.  
  20. await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async ()=&gt;
  21. {
  22. var message =newMessageDialog
  23. (“The Skype contact has been written to the tag.”);
  24. await message.ShowAsync();
  25. });
  26. });
  27. }
  28. }
  29. }

We used the skype uri to create the link, for example the uri is skype:amrsader? call so this will open the skype and call the contact which is amrsaderin this case then using the WindowsUri:WriteTag we specified that its a uri can only be transmitted to a tag. Now we only need to tap the tag to the device and it will work.

real time progress bar for downloading in Windows 8.1

In this blog post I am going to show how to use Background Transfer feature to download files over HTTP in a Windows Store C#/XAML app. Background Transfer has many advantages over using traditionl HttpClient and is much better for long running transfers. I am going to create a simple app, that initiates download over the Internet, tracks progress of the download and supports re-attaching transfers after the app is closed.

So first of all i am going to create a new Project.

I will go to MainPage.xaml and will create a progress bar and Download button.

 

 

So now i will write its csharp code

  1. usingSystem;
  2. usingSystem.Collections.Generic;
  3. usingSystem.IO;
  4. usingSystem.Linq;
  5. usingSystem.Runtime.InteropServices.WindowsRuntime;
  6. usingSystem.Threading.Tasks;
  7. usingWindows.Foundation;
  8. usingWindows.Foundation.Collections;
  9. usingWindows.Networking.BackgroundTransfer;
  10. usingWindows.Storage;
  11. usingWindows.UI.Popups;
  12. usingWindows.UI.Xaml;
  13. usingWindows.UI.Xaml.Controls;
  14. usingWindows.UI.Xaml.Controls.Primitives;
  15. usingWindows.UI.Xaml.Data;
  16. usingWindows.UI.Xaml.Input;
  17. usingWindows.UI.Xaml.Media;
  18. usingWindows.UI.Xaml.Navigation;
  19.  
  20. // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
  21.  
  22. namespaceApp1
  23. {
  24. ///
  25.  
  26. /// An empty page that can be used on its own or navigated to within a Frame.
  27. ///
  28. publicsealedpartialclassMainPage:Page{
  29.  
  30. privateDownloadOperation _activeDownload;
  31.  
  32. private async voidDownloadClick(object sender,RoutedEventArgs e)
  33. {
  34. conststring fileLocation
  35. =http://www.microsoft.com/global/surface/en/us/renderingassets/surfacespecsheet.pdf&#8221;;
  36. var uri =newUri(fileLocation);
  37. var downloader =newBackgroundDownloader();
  38. StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync(“FileName.pdf”,
  39. CreationCollisionOption.ReplaceExisting);
  40. DownloadOperation download = downloader.CreateDownload(uri, file);
  41. await StartDownloadAsync(download);
  42. }
  43.  
  44. privatevoidProgressCallback(DownloadOperation obj)
  45. {
  46. double progress
  47. =((double)obj.Progress.BytesReceived/ obj.Progress.TotalBytesToReceive);
  48. DownloadProgress.Value= progress *100;
  49. if(progress >=1.0)
  50. {
  51. _activeDownload =null;
  52. DownloadButton.IsEnabled=true;
  53. }
  54. }
  55.  
  56. private async TaskStartDownloadAsync(DownloadOperation downloadOperation)
  57. {
  58. DownloadButton.IsEnabled=false;
  59. _activeDownload = downloadOperation;
  60. var progress =newProgress<DownloadOperation>(ProgressCallback);
  61. await downloadOperation.StartAsync().AsTask(progress);
  62. }
  63.  
  64.  
  65. }
  66.  

First of all we need to obtain StorageFile (or more precisely IStorageFile implementation) – in our scenario we use ApplicationData.Current.LocalFolder.CreateFileAsync() to create a file in local app data store. Please note that we use async/await pattern, hence the event handling method is marked as async. We also need to create BackgroundDownloader class instance that is used to actually create new download using CreateDownload() method.

Every download created using Background Tranfser feature is encapsulated in DownloadOperation object. These objects provide basic operations used to manipulate the download. In example above we start the download using StartAsync() that returns IAsyncOperationWithProgress. We make use of AsTask() extension method to cast the returned value to Task and provide progress callback used to update ProgressBar control.

 

Download Progress

  1. async voidMainPageLoaded(object sender,RoutedEventArgs e)
  2. {
  3. await LoadActiveDownloadsAsync();
  4. }
  5. private async TaskLoadActiveDownloadsAsync()
  6. {
  7. IReadOnlyList<DownloadOperation> downloads =null;
  8. downloads = await BackgroundDownloader.GetCurrentDownloadsAsync();
  9. if(downloads.Count>0)
  10. {
  11. //for simplicity we support only one download
  12. await ResumeDownloadAsync(downloads.First());
  13. }
  14. }
  1. private async TaskResumeDownloadAsync(DownloadOperation downloadOperation)
  2. {
  3. DownloadButton.IsEnabled=false;
  4. _activeDownload = downloadOperation;
  5. var progress =newProgress<DownloadOperation>(ProgressCallback);
  6. await downloadOperation.AttachAsync().AsTask(progress);
  7. }

Once we have this code in place our download will reattach every time we load the page. For simplicity we support only one active download.