SALESmanago Mobile – Flutter libraries

The project was created for clients who use the Flutter framework in their mobile applications. This framework enables development of cross-platform solutions. The project is officially developed and supported by Google.

The library provided as a plugin allows you to integrate your application with SALESmanago Mobile. The integration involves adding the plugin as a dependency within the project.

Scope of integration

Integration and contact synchronization enables you to:

  • measure the amount of time a user spends on a given screen within your mobile app,
  • monitor events like button clicks,
  • handle notifications,
  • transfer basic contact data,
  • upload geolocation data.

All features are available for both Android users and iOS users.

Implementation

To perform the integration, follow the instructions below.

1. Adding the plugin to the project in Flutter

In the pubspec.yaml file add the dependency – am_monitor_plugin plugin.

Then run the command from the terminal to install the plugin:

flutter pub get

2. Android

In the project_name/android/libsfolder, place the library using the .aar format.You can find the library on the Developers | SALESmanago page. Then, in the build.gradlefile, add the dependencies used by this library:

dependencies {
   api 'androidx.appcompat:appcompat:1.0.0'
   api 'androidx.legacy:legacy-support-v4:1.0.0'
   api 'androidx.media:media:1.0.0'
   api 'com.google.firebase:firebase-messaging:21.1.0'
   api 'com.google.firebase:firebase-core:18.0.3'
   api 'com.google.android.gms:play-services-location:16.0.0'
   api 'com.google.android.gms:play-services-base:16.1.0'
   api 'androidx.constraintlayout:constraintlayout:1.1.3'
   api 'com.squareup.picasso:picasso:2.5.2'
   api 'com.google.code.gson:gson:2.8.2'
   implementation(name: 'appmanagolibrary-firebase-release', ext:'aar')
}

When building your app, you may receive errors saying that you need to overwrite elements in AndroidManifest.xml. If this happens, use Manifest Merger.

3. iOS

Follow the iOS integration manual, except for the implementation of the methods for the AppDelegate class. These methods are already included in the plugin.

The CocoaPods dependency manager and a properly configured Podfile are required to enable the plugin to work properly:

pod install

Executing this command will add the necessary packages to Flutter.

4. Using the plugin features

You will find a description of how the methods provided by the plugin work at https://support.salesmanago.com/developers/.

Importing a plugin class with an example of creating a plugin class object:

import 'package:am_monitor_plugin/am_monitor_plugin.dart';
final _amMonitorPlugin = AmMonitorPlugin();

Counting time spent in modules:

It is important that the _amMonitorPlugin.create("simpleModuleId") and _amMonitorPlugin.eventStart("simpleModuleId") methods are called right at the beginning; for example, in the widget’s initState method.

The _amMonitorPlugin.eventEnded("simpleModuleId") method should be called before the user moves to the next screen or the app starts running in the background so that the time spent in the module is counted correctly.

Synchronizing email address and phone number:

_amMonitorPlugin.syncEmail("email@test.com")
_amMonitorPlugin.syncMsisdn("+48123456789")

Counting the number of methods performed for the user:

_amMonitorPlugin.clicked("simpleModuleID", "functionID")

Sending internal events:

_amMonitorPlugin.eventCustom("u_customEvent", {
 "textParameterName": {"type": "text", "value": "Some tekst"},
 "numberParameterName": {"type": "integer", "value": 123},
 "doubleParameterName": {"type": "double", "value": 123.12},
 "dateParameterName": {"type": "date", "value": DateTime.now().millisecondsSinceEpoch},
 "booleanParameterName": {"type": "boolean", "value": true}
}

Sending contact information:

_amMonitorPlugin.sendUserProperties({
 "text": {"type": "text", "value": "Tekst"},
 "howMuch": {"type": "integer", "value": 123},
 "precision": {"type": "double", "value": 123.12},
 "when": {"type": "date", "value": DateTime.now().millisecondsSinceEpoch},
 "isItTrue": {"type": "boolean", "value": true}
}

Sending geolocation:

final position = await Geolocator.getCurrentPosition();
_amMonitorPlugin.sendLocation(position.latitude.toString(), position.longitude.toString());
If you need more information about the topic mentioned above, please contact us: support@salesmanago.com +1 800 960 0640