Windows Phone 8 - Company Hub Development - Jean-Sébastien Dupuy - Site Home - MSDN Blogs

Windows Phone 8 - Company Hub Development

Windows Phone 8 - Company Hub Development

  • Comments 5

A Company Hub ?

Since the arrival of Windows Phone 8, Microsoft offers businesses the opportunity to develop enterprise portals (Company Hub) to publish applications for their employees. The aim is to provide business applications, necessary for the needs of a corporation, without validation or publication on the Microsoft Windows Phone Store. In addition to the applications management part, an enterprise portal is also a communication tool: it can relay information to employees (organizational changes, health server status ...). You can use Push Notifications, Live Tiles and Lock Screen to improve the visibility of these communications.imageThis article covers the steps prior to the establishment of a Company Hub and the development parts used to make this portal. Deployment is manual and I do not use MDM (Mobile Device Management) solution such as Windows Intune or System Center Configuration Manager 2012. If you opt for a managed deployment, keep in mind that these softwares natively offer a company portal (Windows Phone 8 Company Portal App) ready to use. For more details, I suggest to read the following articles:

  
Let’s go ! Although the procedure can seem a bit long, the idea is relatively simple. To install applications outside of Windows Phone Store, you must obtain a certificate that gives you this privilege and that identifies your company. Once this certificate in hand, you must associate the phones to your company and sign all your applications with the certificate. The Company Hub is an application like any other, it must also be signed.

What are the steps?

1. Windows Phone Developer Account

To start, the company registers a developer account on Windows Phone Dev Center and retrieves a publisherID (99$ per year). This procedure is standard, make sure you simply select Company (not Individual/Student) when selecting the account. (see Registration info).

2. Enterprise Mobile Code Signing Certificate (from Symantec)

The company acquires an Enterprise Mobile Code Signing Certificate from Symantec (299$ per year). This step allows you to import the certificate on the station and then export them in .pfx format. Make sure to include the private key when exporting.

You are now the proud owner of a certificate in .pfx format. This certificate will allow us to obtain an Enrollment Application Token (EAT) that is used to associate the phones to your company account - it is a prerequisite for the deployment of applications. This certificate will also help us to sign all applications (.xap) distributed outside of Windows Phone Store (including the Company Hub application that you will develop).     
   
To clarify, EAT token deploys the certificate on the phone, and the phone is now accepting applications signed with this certificate.

3. Enrollment Application Token (EAT)

To create the famous EAT token, simply use AETGenerator.exe tool. It is available when you install the Windows Phone SDK 8.0 in the %ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.0\Tools\AETGenerator folder.

  • Start the VS2012 x86 Native Tools Command Prompt with administrator rights. Browse to the directory where the certificate is stored.
  • Run the command line AETGenerator.exe PFXFile Password

 

image

Three files are generated, the only interest is EAT.eatx. This file can be sent by email or downloaded from Internet Explorer for manual deployment on mobile. If you opt for a management software such as Windows Intune or System Center 2012, proposed other files become useful ^^

4. Prepare applications for distribution 

As stated previously, all applications distributed from your enterprise portal must be signed with a certificate from Symantec. In addition, we have to precompile all managed assemblies included in the .xap package to native code.

Two separate tools are available from the Windows Phone SDK 8.0: MDILXAPCompile to precompile and XapSignTool for signature. The developers had the good idea to provide a PowerShell script named BuildMDILXap.ps1 to simplify our lives and perform these two tasks. This script is available in the %ProgramFiles(x86)%\Microsoft SDKs\Windows Phone\v8.0\Tools\MDILXAPCompile folder.

Start a command prompt to run the PowerShell command BuildMDILXap.ps1 -xapfilename XAP -pfxfilename PFXFile -password Password

image

5. Portal development company (Company Hub) 

The Company Hub is an application like others, which must itself be signed by the company certificate to be deployed on mobile. You manage the applications that you want to provide to employees, by the way you have to maintain a catalog of applications, usually via a web service to return the metadata (Name of the application, Description, Version, Url of the .xap file, Url of the thumbnail, ...). If needed, you can add an application rating, the visual display … features provided by the Microsoft Windows Phone Store.

Finally some line of code ... ^ ^

How to install an application from the Company Hub?
InstallationManager.AddPackageAsync(String, Uri) installs the remote .xap file on the mobile. It can be used in addition IAsyncOperationWithProgress to subscribe to Progress event and notify the user of the progress of the installation.    

This event will be called 4 times:
- 5% completed (when the phone displays a pop-up window that asks the user to confirm the installation)
- 10% completed (when user has accepted the installation)
- 55% completed (when the application is downloaded)
- 100% completed (when the application is installed) 

And here is the code ready ...

// The asynchronous operation that represents the installation process
Windows.Foundation.IAsyncOperationWithProgress<PackageInstallResult, uint> installTask = null;

private async Task<PackageInstallResult> InstallPackage(string appTitle, Uri appUri)
{
try
{
installTask = InstallationManager.AddPackageAsync(appTitle, appUri);

installTask.Progress = (installResult, progress) => Dispatcher.BeginInvoke(() =>
{
StatusTextBlock.Text = "Progress: " + progress;
});
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}

return await installTask;
}
… and the way to call it :
 
Uri appUri = new Uri(@"http://companyhub.blob.core.windows.net/applications/Techdays2013.xap");
string appTitle = "TechDays 2013";

await InstallPackage(appTitle, appUri);
    

How to list installed applications?
InstallationManager.FindPackagesForCurrentPublisher will allow us to recover all the packages installed on the phone from the same Publisher that the current application. So beware, we no longer speak of the certificate to identify the packages, but simply the Publisher ID stored in WMAppManifest.xml file. Make sure that your packages have the correct Guid. This identifier is available in your account information on Windows Phone Dev Center.

This method returns an IEnumerable <Package>. The Package class has the benefit of offering two useful methods:

- GetThumbnailToken to retrieve the application Thumbnail.
- Launch to start the application directly from the Company Hub.

Few lines of code to clarify the point:

private async Task<BitmapImage> GetThumbnailFromPackage(Package package)
{
BitmapImage bitmap= new BitmapImage();

try
{
// A token that can be used to retrieve the thumbnail image associated with this application package.
string token = package.GetThumbnailToken();

// Retrive the thumbnail image associated with this application package, copy the thumbnail to LocalFolder.
string filename = SharedStorageAccessManager.GetSharedFileName(token);
var file = await SharedStorageAccessManager.CopySharedFileAsync(
ApplicationData.Current.LocalFolder, //destinationFolder
filename, //desiredName
NameCollisionOption.ReplaceExisting,
token) as StorageFile;

// Retrieve the stream for reading
var stream = await file.OpenStreamForReadAsync();

// Set bitmap source
bitmap.SetSource(stream);

}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}

return bitmap;
}

private async void LoadInstalledPackages()
{
IEnumerable<Package> packages = InstallationManager.FindPackagesForCurrentPublisher();

foreach (Package package in packages)
{
// AppMetadata is a custom class used to store application name, version, thumbnail
AppMetadata metadata = new AppMetadata();
metadata.Name = package.Id.Name;
metadata.AppPackage = package;
metadata.Thumbnail = await GetThumbnailFromPackage(package);

// Associate metadata to my ViewModel
App.ViewModel.InstalledPackages.Add(metadata);
}
}

 

6. Last but not least ... the deployment of your solution!

If you've reached this point, you probably want to distribute your Company Hub to employees of the company. As our deployment is manual, two options are available:

wp_ss_20130308_0003 

Send an email to your employees with the .eatx file in attachment and the link to download the Company Hub package (.xap). In this case, apply IRM protection to email.

- Or -

Download with Internet Explorer the .eatx file, then the Company Hub package (.xap) from a secure website.

Then enjoy your new enterprise portal!

Leave a Comment
  • Please add 7 and 4 and type the answer here:
  • Post
  • I think that is a great feature that will drive WP8 growth in the enterprise business. There is a Visual Studio extension called http://radarc.net to quickly create Line Of Business app (enterprise apps). You can model your app or import a model from an existing database, and Radarc will generate the code for the app using a reference architecture. You can then extend that code to evolve the app. Check it out!

  • Really Helpful post !!!

    Can we update and Uninstall/Remove Installed Enterprise application through Company Hub ..?

  • I love the thoughts and nice article, but i would prefer www.eastcoasttelephone.com for my provider.

  • Where did you get the file 'Techdays2013.xap'?

  • Enterprise hub development for sharing the windows 8 applications development is an excellent feature and this allows developers not to wait in queue to release their apps, right??

    I have a doubt, does this hub creation supports the windows phone users only inside the company or the third party people can also use the app which company publish?

Page 1 of 1 (5 items)