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
- Flutter CLI and PMF CLI installed on the developer workstation.
- A local or remote instance of PMF is running.
- Read the Setting up your PMF development environment and Setting up your Flutter development environment tutorials.
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
-
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.
-
Change directory to the root of the Flutter project by using the following command.
cd hello
- Download the SDK
.zip
file from the PMF Operations Console → Download Center → SDKs tab and extract the downloaded file. -
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
-
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
-
Download the SDK
.zip
file from the PMF Operations Console → Download Center → SDKs tab and extract the downloaded file. -
Uninstall the existing PMF Flutter plug-in by using the following command.
flutter pub remove flutter_pmf
-
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
-
iOS: Navigate to the iOS platform location and update the pods by using the following command.
cd ios pod install cd ..
-
Link the plug-in libraries by running the command:
flutter link
Registering the application
-
Open a command-line window and navigate to the root of the particular platform (iOS or Android) of the project.
-
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 themfpclient.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.
- Load the PMF Operations Console.
- 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:
- Review the Adapters development tutorials.
-
Review the Authentication and security tutorials.
- Review the Notifications tutorials.