Configuring a native Windows Phone 8 application with the MobileFirst Platform SDK

improve this page | report issue

Overview

To serve a native Windows Phone 8 (Silverlight) application, MobileFirst Server must be aware of it. For this purpose, IBM MobileFirst Platform Foundation provides a Native API library, which contains a set of APIs and configuration files.

This tutorial explains how to generate the Windows Phone 8 Native API and how to integrate it with a native Windows Phone 8 (Silverlight) application. These steps are necessary for you to be able to use it later on for tasks such as connecting to MobileFirst Server, invoking adapter procedures, implementing authentication methods, and so on.

Prerequisite: Developers are expected to be proficient with Microsoft developer tools.

This tutorial covers the following topics:

Creating a MobileFirst native API

CLI

  1. In the terminal with the CLI installed, create a new MobileFirst project using: $ mfp create HelloWorldNative.
  2. Go to the newly created project directory: $ cd HelloWorldNative/.
  3. Add a new Windows Phone 8 native API using $ mfp add api WP8HelloWorld -e windowsphone8.
  4. Navigate into the native API folder and run the command: $ mfp push. This action is required for MobileFirst Server to recognize the application if it attempts to connect.

Studio

missing_alt

  1. In MobileFirst Studio, create a MobileFirst project and add a MobileFirst Native API.
  2. In the New MobileFirst Native API dialog, enter your application name and select Windows Phone Sliverlight 8 for the Environment field.
  3. Right-click the generated NativeAPI folder (located in your-projects/apps/your-nativeapi-app-name) and select Run As > Deploy Native API.
    Note: This action is required for MobileFirst Server to recognize the application if it attempts to connect.

The MobileFirst native API contains several components:

  • The worklight-windowsphone8.dll file is a MobileFirst API library that you must copy to your native WP8 project. This can be found in "buildtarget" folder under the respective hardware architecture.
  • The Newtonsoft.Json.dll file is a library that provides JSON support.
  • The application-descriptor.xml file defines application metadata and security settings that MobileFirst Server enforces.
  • The wlclient.properties file contains connectivity settings that a native Windows Phone 8 Silverlight application uses. You must copy this file to your native Windows Phone 8 Silverlight project.
  • As with any MobileFirst project, you create the server configuration by modifying the files that are in the server\conf folder.

The wlclient.properties file

You can edit the wlclient.properties file to set connectivity information.

  • wlServerProtocol – The communication protocol to MobileFirst Server, which is either http or https.
  • wlServerHost – The host name of the MobileFirst Server instance.
  • wlServerPort – The port of the MobileFirst Server instance.
  • wlServerContext – The context root path of the application on MobileFirst Server.
  • wlAppId – The application ID as defined in the application-descriptor.xml file.
  • wlAppVersion – The application version.
  • wlEnvironment – The target environment of the native application.
  • wlPlatformVersion – The MobileFirst SDK version.
  • languagePreferences – The list of preferred locales.

Creating and configuring a Windows Phone 8 native application

  1. Create a Windows Phone Silverlight project or use an existing one.
  2. Add as a reference the worklight-windowsphone8.dll and Newtonsoft.Json.dll files.Choose the right worklight-windowsphone8.dll from the folder that matches the architecture of the target device (ARM/x86).
  3. Copy the wlclient.properties file to the root of the native project.
  4. In Visual Studio, open the wlclient.properties Properties window and set the Copy to Output Directory option to Copy always.
  5. Add the following capabilities to the WMAppManifest.xml file:
    ID_CAP_NETWORKING
    ID_CAP_IDENTITY_DEVICE

For more information, see the topic about developing native C# applications for Windows Phone 8, in the user documentation.

Tutorials to follow next

Now that your application contains the Native API library, you can follow the tutorials in the Native WP8 Development section to learn more about authentication and security, server-side development, advanced client-side development, notifications and more.

Inclusive terminology note: The Mobile First Platform team is making changes to support the IBM® initiative to replace racially biased and other discriminatory language in our code and content with more inclusive language. While IBM values the use of inclusive language, terms that are outside of IBM's direct influence are sometimes required for the sake of maintaining user understanding. As other industry leaders join IBM in embracing the use of inclusive language, IBM will continue to update the documentation to reflect those changes.
Last modified on December 02, 2015