Windows Universal Apps: Part 1 - Native C# apps
In April 2014 Microsoft announced Universal Apps for Windows 8.1 . Universal app development is a paradigm in which you can use a lot of shared code between Windows Tabs and Windows Phone. In 8.1 – Microsoft introduced the Windows Runtime API (Win RT) that works on the Windows Phone 8.1 as well. Up until Windows Phone 8.0 – the Windows Phone apps were Windows Silverlight apps. Silverlight Phone apps don’t migrate to the Windows tablet world; they have to be re-written. Starting 8.1 you can write Windows Phone apps using the Win RT API – the same API you used to use to build the Windows tablet apps. A detailed explanation is available in a MS IT Camp presentation by Dan Ardelean
IBM MobileFirst Windows SDKs
Note: At the time of the article the IBM MobileFirst Foundation 7.0 does not have a formal support for Windows Universal apps
IBM MobileFirst 7.0 has 4 SDKs available for Windows app developers. The WindowsPhone8 native and hybrid and Windows8 native and hybrid. The Hybrid SDKs are for developing Cordova Hybrid apps across all phone types.
Building IBM MobileFirst Windows Universal C# apps (Native)
In this post we will see how you can build a IBM MobileFirst Windows Universal native C# app using the Windows 8 Native SDKs. If you are new to Windows Universal apps, a very detailed article is available in the Windows dev center. The IBM MobileFirst Windows8 SDK is written on Windows RT APIs. So it also happens to work on Windows Phone 8.1. This will however not work on Windows Phone 8.0 as Windows Phone 8.0 can run only Silverligt apps. If you have written a app for Windows 8 tabs, you can migrate them to a Windows phone app pretty easily by adding a Windows Phone project to it
1. Create the IBM MF Windows 8 native app
This will give you the necessary Windows artifacts to create the universal app.
This also is the “server environment” that you will be connecting to from your app from the tab as well as the phone.
2. Create the Universal App
a. New Visual Studio project
In a Visual Studio 2013 solution – create a Windows Universal C# App.
This in fact adds 3 projects to your solution
1. [appname].Windows (Windows 8.1)
2. [appname].WindowsPhone (Windows Phone 8.1)
3. [appname].shared (shared code)
So as you can see in essence you are still creating and maintaining 2 apps.
b. Migrating from existing Windows 8 project
If you have a existing IBM MF Windows8 app – its easy to convert it to a Universal app. Right click on the [appname].Windows project in your solution and select “Add Phone app”. This will bring your solution to the Universal app template as above.
3. Add the IBM MF artifacts to your Windows Phone 8.1 project
Now add the following as
References to the project from the location that the IBM MF Windows8 native app.
Add > Existing item the wlclient.properties file to the root of the project . Make sure you
- Build Action = Content
- Copy to Output Directory = Copy Always
If you are migrating from a existing project – you would have already done this for the Windows 8.1 project. If this is a brand new project – repeat this for the Windows 8.1 project as well.
4. Code the app
Now you are ready to add code to the app. You can use the getting started as a starting point. For push notifications refer to the Windows 8 Native section. Once you are done coding your app – the build will produce 2 installers one for the tab app and one for the phone that you can use to submit to the app stores.
All the features of the IBM MF Windows8 SDK should work on the Windows Phone 8.1 as well. Make sure you refer to the SDK as the IBM MF Windows 8 Native SDK and not the Windows Phone SDK. The Existing IBM MF Windows Phone SDK is Silverlight based and none of features of that SDK are applicable to the apps built for the Windows Phone 8.1 using the IBM MF Windows 8 SDK.
Let me know your experience in using the IBM MobileFirst Windows 8 Native SDK in a Windows Universal app.