Monday, February 8, 2016

Integrating SharePoint to a Universal App

Recently I came through a requirement that I thought worth trying out a Universal App that consumes SharePoint data. I have chosen Windows 8.1 and Windows Phone 8.1 as the minimal platforms and to support upwards. 

Universal apps bring the power of writing one code that work on both phone and desktop/ tablet devices. This can be done easily in order to create an app that consumes SharePoint data.

This is made simple with the support of C# Managed Code Client Side Object Model. What you need to do is to reference the client side assemblies along with the run-time assemblies. 


Following is a screenshot of my solution explorer. 

As you can see, it has 3 projects each ending with .Windows, .WindowsPhone and .Shared. The suffix suggests where they belongs. I have put the XAML files into the Shared project but it is good if you keep them separated as they may require specific changes according to the device. For a simple solution, this works.

As you can see, I have referenced Microsoft.SharePoint.Client.Portable and Microsoft.SharePoint.Client.Runtime.Portable assemblies in both Windows app project as well as the Windows Phone app project. These are what get used within the Shared project. You need to add the portable assembly for both the projects. Then there are different run time assemblies for two projects. For the Windows Phone it has Microsoft.Client.Runtime.WindowsPhone assembly and for the Windows app it has Microsoft.SharePoint.Client.Runtime.WindowsStore. 

Have you got the assemblies added? Now you are good to go....

You can add the common code to the Shared project and save the lines of code. 

Happy coding and SharePointing...

No comments:

Post a Comment