Adding the Persistent Mobile Foundation SDK to .NET MAUI Applications

Release 9.0.6

The PMF SDK consists of a collection of dependencies that are packaged inside a NuGet package that can be added to your Visual Studio project.

The packages correspond to core functions and other functions:

  • PersistentMobileFoundation.Android- Contains MobileFirst client SDK libraries which implements client-to-server connectivity, handles authentication and security aspects, resource requests, and other required core functions along with JSONStore framework. Also, contains the push notification framework.

  • PersistentMobileFoundation.ios - Contains MobileFirst client SDK libraries which implements client-to-server connectivity, handles authentication and security aspects, resource requests, and other required core functions along with JSONStore framework. Also Contains the push notification framework. For more information, review the Notifications tutorials.

In this tutorial you learn how to add the PMF Native SDK by using NuGet Package Manager to a new or existing MAUI (Android/iOS) application. You also learn how to configure the PMF to recognize the application.

Prerequisites

Jump to:

Add .NET MAUI SDK to application

Follow the instructions below to add the PMF Native SDK to a new or existing Visual Studio project, and to register the application to the PMF.

Before you start, make sure that the PMF Server is running.

If using a locally installed server:

From a Command-line window, navigate to the server’s folder and run the command:

./run.sh

  1. Create an application. Create a MAUI solution using Visual Studio or use an existing one.
  2. Download .NET MAUI SDKs. You can download MAUI SDKs (PersistentMobileFoundation.Android and PersistentMobileFoundation.ios) from this path.

    Download the SDK.zip file from the PMF Operations Console → Download Center → SDKs tab.

  3. Add .NET MAUI SDKs to application.

    After you have downloaded MAUI SDKs from the location, keep those SDKs in a convenient folder location to add them through the package source.

Configuring new package source

  1. Right-click on Packages folder of the .NET MAUI Project and select Manage NuGet Packages option.

    Adding sdk from nuget.org

  2. Select Configure Resources from the pop-up window.

    Configure Resources

  3. Specify following inputs to add new package resource.

    • Name : Package Resource Name
    • Location : Path to the folder where you have kept the Persistent Mobile Foundation Nuget files.
    • Username : Optional
    • Password : Optional

    Add new Package Resource

  4. The new package resource is listed as shown.

    Successful addition

  5. Select your new package resource from the Package source drop-down.

    Resource dropdown

    Above image shows PMF_Nuget pointing a custom local path to Nuget files.

Updating the .NET MAUI Application .csproj file

Update the .csproj file to specify platform-specific references for the Persistent Mobile Foundation SDK:

Android-specific reference

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0-android'">

<PackageReference Include="PersistentMobileFoundation.Android" Version="9.0.6" />

</ItemGroup>

iOS-specific reference

<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'iOS'">

<PackageReference Include="PersistentMobileFoundation.ios" Version="9.0.6" />

</ItemGroup>

Registering the application

  1. Load the PMF Operations Console.
  2. Click New 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 AndroidManifest.xml and Info.plist respectively.

  3. 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

mfpclient.plist

  1. Right-click the .NET MAUI iOS project and select Add files. Browse and find the mfpclient.plist to the root of the project. If prompted, choose Copy file to project.
  2. Right-click the mfpclient.plist file and select Build action. Choose Content.

mfpclient.properties

  1. Right-click the Assets folder of .NET MAUI Android project and select Add files. Browse and find the mfpclient.properties to the folder. If prompted, choose Copy file to project.
  2. Right-click the mfpclient.properties file and select Build action. Choose Android asset.

Referencing the SDK

Whenever you want to use the PMF Native SDK, make sure that you import the PMF framework:

CommonProject

using Worklight;

iOS

using MobileFirst.Xamarin.iOS;

Android

using Worklight.Xamarin.Android;

Updating the PMF Native SDK

To update the Persistent Mobile Foundation Native SDK with the latest release, remove the older nuget and add a new nuget.

Generated PMF Native SDK artifacts

mfpclient.plist

This file defines the client-side properties used for registering your iOS app on the PMF.

Property Description Example values
protocol The communication protocol with the PMF. http or https
host The host name of the PMF. 192.0.2.63
port The port of the PMF. 9080
wlServerContext The context root path of the application on the PMF. /mfp/
languagePreferences Sets the default language for client sdk system messages. en

Tutorials to follow next

With the PMF Native SDK now integrated, you can now:

Last modified on