This sample illustrates the basic components and functionality required to build a Company Hub app. When the app runs, it enumerates the company apps that are available to a user, and then the user can select, install, and launch an app from the list.

Note:

This sample requires additional work to enable the functionality described. For details, see Steps to build and run the sample.

This sample shows you how to do the following:

  • Define a schema for company app management.

  • Enumerate the install status of company apps.

  • Allow a user to initiate the installation of a company app.

  • Allow a user to launch an installed company app.

This sample uses the Windows Phone installation manager and app model APIs. For more info about company apps and using a Company Hub in Windows Phone 8, see Company app distribution for Windows Phone and Developing a Company Hub app. For more info about the APIs, see the Windows.Phone.Management.Deployment and Windows.ApplicationModel API reference pages.

Steps to build and run the sample

  1. Register as a company account on Windows Phone Dev Center. For more info about registering for a Dev Center account, see Registration info.

  2. Acquire an enterprise mobile code signing certificate from Symantec. This certificate is required to generate an application enrollment token (AET) and sign company apps. To acquire the certificate, visit the Symantec Enterprise Mobile Code Signing Certificate website.

  3. Import the certificate from Symantec and then export it in PFX format. Be sure to export the private key with the certificate. For info about importing and exporting the certificate, see How to install the Windows Phone Private Enterprise Root and Intermediate certificates on the Symantec website and How to generate an application enrollment token on MSDN.

  4. Create an AET using the AETGenerator tool provided with Windows Phone SDK 8.0. The AET is used to enroll phones in the company account, which is a prerequisite for installing apps published by the company. For more info about creating the AET, see How to generate an application enrollment token.

  5. Obtain or create a few apps to use with the sample. These mock company apps are just for demonstration purposes and do not need to do anything, but they must match the publisher ID of the Company Hub app and should have an associated app icon.

  6. Prepare the company apps for distribution using the guidance at Preparing company apps for distribution.

  7. Upload the prepared company apps (XAPs) and their app icons to a secure site (such as Azure storage) that the Company Hub app can access.

  8. Create an XML file that lists the company apps, their download URLs, and their product IDs as shown in the following code example. Although the format shown here isn’t required for Company Hubs in general, it is required for this specific sample to function.

     
    <?xml version="1.0"?>
    <!--This is an example file that demonstrates how a company might expose metadata and download 
        URLs for their XAPs and icons. The data below assumes that the XAPs and icons are stored in
        Azure storage blobs, but they can be stored in any secure site that is accessible from the 
        app. For more information about this file, see the comments in MainPage.xaml.cs.-->
    <Applications>
      <App Name="CompanyApp1"
           IconUrl="http://contosostorage.blob.core.windows.net/companyapps/CompanyApp1.png"
           XapUrl="http://contosostorage.blob.core.windows.net/companyapps/CompanyApp1_Debug_AnyCPU.xap" Version="1.0.0.0"
           ProductId="{f42567e5-14d8-4bfc-ad05-9dc2150c7614}" Description="This is CompanyApp1" /> 
      <App Name="CompanyApp2"
           IconUrl="http://contosostorage.blob.core.windows.net/companyapps/CompanyApp2.png"
           XapUrl="http://contosostorage.blob.core.windows.net/companyapps/CompanyApp2_Debug_AnyCPU.xap" Version="1.0.0.0"
           ProductId="{6695006b-a359-4f60-aed4-ca07d2ae000d}" Description="This is CompanyApp2" />
      <App Name="CompanyApp3"
           IconUrl="http://contosostorage.blob.core.windows.net/companyapps/CompanyApp3.png"
           XapUrl="http://contosostorage.blob.core.windows.net/companyapps/CompanyApp3_Debug_AnyCPU.xap" Version="1.0.0.0"
           ProductId="{4776d64b-14e7-4cc2-b20a-fb080ffc6f33}" Description="This is CompanyApp3" /> 
    </Applications>
  9. Upload the XML file to a secure site that the Company Hub app can access.

  10. Start Visual Studio Express 2012 for Windows Phone and select File > Open > Project/Solution.

  11. Go to the directory in which you unzipped the sample. Double-click the Visual Studio Express 2012 for Windows Phone solution (.sln) file.

  12. Modify the URI used by the WebClient in the Company Hub sample MainPage.xaml.cs file with the URL for the XML file you created.

     
    client.DownloadStringAsync(new Uri("http://contosostorage.blob.core.windows.net/companyapps/Applications.xml"));
  13. Select Build > Rebuild Solution to build the sample.

  14. Prepare the Company Hub app sample for distribution using the guidance at Preparing company apps for distribution.

  15. Email the AET file and the Company Hub XAP to your device to test the sample.

    Note:

    Alternatively, these files could be provided through a secure website. Although not necessary for the sample, when distributing a production Company Hub, Microsoft recommends using Information Rights Management (IRM) if you choose email for the app distribution method.

  16. From email, tap the AET file to enroll the device.

  17. From email, tap the XAP to install the Company Hub app.

  18. Go to the App list on the phone and launch the Company Hub app to view, install, and launch your company apps.

    Note:

    For additional info about this process, see Company app distribution for Windows Phone on MSDN.

See also