flutter_acpplaces_monitor

pub package Build License

flutter_acpplaces_monitor is a flutter plugin for the iOS and Android AEP Places Monitor SDK to allow for integration with flutter applications. Functionality to enable the PlacesMonitor extension is provided entirely through Dart documented below.

Installation

Add flutter_acpcore, flutter_acppplaces and flutter_acpplaces_monitor to your dependencies in pubspec.yaml

dependencies:
  flutter_acpcore: ">= 2.0.0"
  flutter_acpplaces: ">= 2.0.0"
  flutter_acpplaces_monitor: ">= 2.0.0"

Then fetch the packages with:

flutter pub get

Tests

Run:

flutter test

Usage

PlacesMonitor

Importing the SDK:
import 'package:flutter_acpplaces_monitor/flutter_acpplaces_monitor.dart';
Getting the SDK version:
String version = FlutterACPPlacesMonitor.extensionVersion;
Registering the extension with ACPCore:

Note: It is required to initialize the SDK via native code inside your AppDelegate and MainApplication for iOS and Android respectively. For more information see how to initialize Core.

iOS
#import "ACPCore.h"
#import "ACPPlaces.h"
#import "ACPPlacesMonitor.h"

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions {
   [ACPCore configureWithAppId:@"yourAppId"];
   [ACPPlaces registerExtension]; //Register Places with Core
   [ACPPlacesMonitor registerExtension]; //Register PlacesMonitor with Core
   [ACPCore start: nil];

   return YES;
}

The following updates are also neccessary for Places Monitor on iOS:

Android:

Within the App's OnCreate method, register the SDK extensions and start the Places Monitor:

import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Places;
import com.adobe.marketing.mobile.PlacesMonitor;

public class MobileApp extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        MobileCore.setApplication(this);
        MobileCore.ConfigureWithAppId("yourAppId");
        try {
            Places.registerExtension(); //Register Places with Core
            PlacesMonitor.registerExtension(); //Register PlacesMonitor with Core
            MobileCore.start(null);
        } catch (Exception e) {
            //Log the exception
        }
    }
}

The following update is also necessary for Places Monitor on Android:

Start the Places Monitor:
import 'package:flutter_acpplaces_monitor/flutter_acpplaces_monitor.dart';

FlutterACPPlacesMonitor.start();
Stop the Places Monitor:
bool clearPlacesData = true;
FlutterACPPlacesMonitor.stop(clearPlacesData);
Update the device's location:
FlutterACPPlacesMonitor.updateLocation();
Set or upgrade the location permission request (Android) / request authorization level (iOS):
import 'package:flutter_acpplaces_monitor/src/flutter_acpplaces_monitor_location_permission.dart';

FlutterACPPlacesMonitor.setRequestLocationPermission(FlutterACPPlacesMonitorLocationPermission.ALWAYS_ALLOW);
FlutterACPPlacesMonitor.setRequestLocationPermission(FlutterACPPlacesMonitorLocationPermission.WHILE_USING_APP);
FlutterACPPlacesMonitor.setRequestLocationPermission(FlutterACPPlacesMonitorLocationPermission.NONE);
Set the monitoring mode (iOS only):
import 'package:flutter_acpplaces_monitor/src/flutter_acpplaces_monitor_modes.dart';

FlutterACPPlacesMonitor.setPlacesMonitorMode(FlutterACPPlacesMonitorModes.CONTINUOUS);
FlutterACPPlacesMonitor.setPlacesMonitorMode(FlutterACPPlacesMonitorModes.SIGNIFICANT_CHANGES);

Contributing

See CONTRIBUTING

License

See LICENSE