Adding the MobileFirst Foundation SDK to Xamarin Applications
The Mobile Foundation SDK consists of a collection of dependencies that are available through Xamarin Component store and which you can add to your Xamarin project.
The pods correspond to core functions and other functions:
- MobileFirst.Xamarin - Implements client-to-server connectivity, handles authentication and security aspects, resource requests, and other required core functions.
- MobileFirst.JSONStore - Contains the JSONStore framework.
- MobileFirst.Push - Contains the push notification framework. For more information, review the Notifications tutorials.
In this tutorial you learn how to add the MobileFirst Native SDK by using Xamarin Component Store to a new or existing Xamarin Android or iOS application. You also learn how to configure the MobileFirst Server to recognize the application.
- Xamarin Studio installed on the developer workstation.
- A local or remote instance of MobileFirst Server is running.
- Read the Setting up your MobileFirst development environment and Setting up your Xamarin development environment tutorials.
Adding the MobileFirst Native SDK
Follow the instructions below to add the MobileFirst Native SDK to a new or existing Xcode project, and to register the application to the MobileFirst Server.
Before you start, make sure that the MobileFirst Server is running.
If using a locally installed server: From a Command-line window, navigate to the server’s folder and run the command:
Creating an application
Create a Xamarin solution using Xamarin Studio or Visual Studio or use an existing one.
Adding the SDK
- The MobileFirst Native SDK is provided via Xamarin Components Store.
- Expand the Android or iOS project.
- In the Android or iOS project, right-click Components.
- Select Get More Components.
- Search for IBM MobileFirst SDK. Choose and do Add to App.
- Right-click Packages and select Add packages .Search for and add Json.NET. This pulls in the Newtonsoft dependency from Nuget. This needs to be done separately for both Android and iOS projects.
- Right-click References and select Edit References. Go to .Net Assembly tab and click ‘Browse’. From the project folder’s root go to
Components -> ibm-worklight-22.214.171.124 -> lib -> pcl. Select Worklight.Core.dll.
Registering the application
- Load the MobileFirst Operations Console.
- Click the New button next to Applications to register a new application and follow the on-screen instructions.
- Android and iOS applications have to be registered separately. This ensures both the Android application and iOS application can connect successfully to the server. The registration details for Android and iOS applications can be found in the
- After the application is registered, navigate to the application’s Configuration Files tab and copy or download the mfpclient.plist and mfpclient.properties file. Follow the onscreen instructions to add the file to your project.
Completing the setup process
- Right-click the Xamarin iOS project and select Add files... Browse and find the
mfpclient.plistto the root of the project. Choose Copy file to project if prompted.
- Right-click the
mfpclient.plistfile and select Build action.Choose Content.
- Right-click the Assets folder of Xamarin Android project and select Add files... Browse and find the
mfpclient.propertiesto the folder. Choose Copy file to project if prompted.
- Right-click the
mfpclient.propertiesfile and select Build action.Choose Android asset.
Referencing the SDK
Whenever you want to use the MobileFirst Native SDK, make sure that you import the Mobile Foundation framework:
Updating the MobileFirst Native SDK
To update the MobileFirst Native SDK with the latest release, update the version of the SDK via the Xamarin Components store.
Generated MobileFirst Native SDK artifacts
This file defines the client-side properties used for registering your iOS app on the MobileFirst Server.
|protocol||The communication protocol with the MobileFirst Server.||http or https|
|host||The host name of the MobileFirst Server.||192.168.1.63|
|port||The port of the MobileFirst Server.||9080|
|wlServerContext||The context root path of the application on the MobileFirst Server.||/mfp/|
|languagePreferences||Sets the default language for client sdk system messages.||en|
Tutorials to follow next
With the MobileFirst Native SDK now integrated, you can now:
- Review the Adapters development tutorials
- Review the Authentication and security tutorials
- Review the Notifications tutorials
- Review All Tutorials