Adding the Persistent Mobile Foundation SDK to Flutter Applications

In this tutorial, you learn how to add the PMF SDK to a new or existing Flutter application, which has been created with Flutter CLI. You also learn how to configure the PMF to recognise the application, and to find information about the PMF configuration files that are changed in the project.

Download the SDK .ZIP file from the PMF Operations Console → Download Center → SDKs tab or from the Persistent Support portal.

Available plug-in

  • flutter-pmf-sdk - The core SDK plug-in

Flutter SDK components

The flutter-pmf plug-in is the core PMF plug-in for Flutter and is required.

Prerequisites

Jump to

Adding the PMF Flutter SDK

Follow these instructions to add the PMF Flutter SDK to a new or existing Flutter project, and register it in the PMF.

If a remote server is used,

  • Before you start, make sure that the PMF is running.
  • If using a locally installed server, from a command-line window, navigate to the server’s folder and run the following command.

    ./run.sh
    

Adding the SDK

Adding the SDK to a new application

  1. Create a Flutter project with the following name.

    flutter create projectName  
    

    Example

    flutter create Hello
    

    Where,

    Hello is the folder name and name of the application.

  2. Change directory to the root of the Flutter project by using the following command.

    cd hello
    
  3. Download the SDK .zip file from the PMF Operations Console → Download Center → SDKs tab and extract the downloaded file.
  4. Add the Persistent Mobile Foundation plug-ins by using the following command.

    flutter pub add flutter-plugin-name`
    

    Example

     flutter pub add flutter_pmf
    

    The above command adds the Persistent Mobile Foundation Core SDK plug-in to the Flutter project.

    Or, if you need to add from a local path, in the pubspec.yaml file, add the following.

     dependencies:
       flutter_pmf:
         path: ../path_to_extracted_sdk/flutter_pmf
    

    Then run the following command.

    flutter pub get
    
  5. iOS: Navigate to the iOS platform location and update the pods by using the following command.

     cd ios
     pod install
     cd ..
    

Adding the SDK to an existing application

  1. Download the SDK .zip file from the PMF Operations Console → Download Center → SDKs tab and extract the downloaded file.

  2. Uninstall the existing PMF Flutter plug-in by using the following command.

     flutter pub remove flutter_pmf
    
  3. Install PMF Flutter plug-in by using the following command.

     flutter pub add flutter_pmf
    

    Or, if you are using a local path, in the pubspec.yaml file, update the following.

     dependencies:
       flutter_pmf:
         path: ../path_to_extracted_sdkflutter_pmf
    

    Then run the following command.

     flutter pub get
    
  4. iOS: Navigate to the iOS platform location and update the pods by using the following command.

     cd ios
     pod install
     cd ..
    
  5. Link the plug-in libraries by running the command:

    flutter link
    

Registering the application

  1. Open a command-line window and navigate to the root of the particular platform (iOS or Android) of the project.

  2. Register the application to PMF by using the following command.

    pmfdev app register
    
    • iOS: If your platform is iOS then you are asked to provide the application’s BundleID.

      Important: The BundleID is case sensitive.

      The pmfdev app register CLI command first connects to the PMF Server to register the application, then generates the mfpclient.plist file at the root of the Xcode project, and then adds to it the metadata that identifies the PMF Server.

    • Android: If your platform is Android then you are asked to provide the application’s package name.

      Important: The package name is case sensitive.

      The pmfdev app register CLI command first connects to the PMF Server to register the application, then generates the mfpclient.properties file in the [project root]/app/src/main/assets/ folder of the Android Studio project, and then adds it to the metadata that identifies the PMF Server.

    • If a remote server is used, add it by using the following command.

      pmfdev server add
      

    The pmfdev app register CLI command first connects to the PMF to register the application. Each platform is registered as an application in PMF.

You can also register applications from the PMF Operations Console as follows.

  1. Load the PMF Operations Console.
  2. Click the New next to Applications to register a new application and follow the on-screen instructions.

Updating the PMF Flutter SDK

To update the PMF Flutter SDK with the latest release, remove the flutter_pmf plug-in by using the following command.

  flutter pub remove flutter_pmf

Then run the command to add it again.

  flutter pub add flutter_pmf

Generated PMF Flutter SDK artifacts

Android environment

mfpclient.properties

Located in the ./app/src/main/assets/ folder of the Android Studio project, this file defines the client-side properties used for registering your Android app on the PMF.

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

iOS environment

mfpclient.plist

Located at the root of the project, this file defines the client-side properties used for registering your iOS app on the PMF.

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

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

Last modified on