flutter_aepcore

pub package Build License

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

Contents

Installation

Install instructions for this package can be found here.

Note: After you have installed the SDK, don't forget to run pod install in your ios directory to link the libraries to your Xcode project.

Usage

Initializing

Initializing the SDK should be done in native code (AppDelegate / SceneDelegate for iOS and Application class for Android). Documentation for initializing the SDK can be found here.

As part of the initialization code, make sure that you set the SDK wrapper type to Flutter before you start the SDK.

Refer to the Initialization section of the root README for more information about initializing the SDK.

Core

For more detailed information on the Core APIs, visit the documentation here

Importing Core:
import 'package:flutter_aepcore/flutter_aepcore.dart';
Getting Core version:
String version = await MobileCore.extensionVersion;
Updating the SDK configuration:
MobileCore.updateConfiguration({"key" : "value"});
Clearing configuration updates back to original configuration:
MobileCore.clearUpdatedConfiguration();
Controlling the log level of the SDK:
MobileCore.setLogLevel(LogLevel.error);
MobileCore.setLogLevel(LogLevel.warning);
MobileCore.setLogLevel(LogLevel.debug);
MobileCore.setLogLevel(LogLevel.trace);
Getting the current privacy status:
PrivacyStatus result;

try {
  result = await MobileCore.privacyStatus;
} on PlatformException {
  log("Failed to get privacy status");
}
Setting the privacy status:
MobileCore.setPrivacyStatus(PrivacyStatus.opt_in);
MobileCore.setPrivacyStatus(PrivacyStatus.opt_out);
MobileCore.setPrivacyStatus(PrivacyStatus.unknown);
Getting the SDK identities:
String result = "";

try {
  result = await MobileCore.sdkIdentities;
} on PlatformException {
  log("Failed to get sdk identities");
}
Dispatching an Event Hub event:
final Event event = Event({
  "eventName": "testEventName",
  "eventType": "testEventType",
  "eventSource": "testEventSource",
  "eventData": {"eventDataKey": "eventDataValue"}
});
try {
  await MobileCore.dispatchEvent(event);
} on PlatformException catch (e) {
  log("Failed to dispatch event '${e.message}''");
}
Dispatching an Event Hub event with callback:
Event result;
final Event event = Event({
      "eventName": "testEventName",
      "eventType": "testEventType",
      "eventSource": "testEventSource",
      "eventData": {"eventDataKey": "eventDataValue"}
    });
    try {
      result = await MobileCore.dispatchEventWithResponseCallback(event, 1000);
    } on PlatformException catch (e) {
      log("Failed to dispatch event '${e.message}''");
    }
Reset identities
MobileCore.resetIdentities()
Track app actions

Important

trackAction is supported through Edge Bridge and Edge Network extensions.

MobileCore.trackAction("myAction",  data: {"key1": "value1"});
Track app states

Important

trackState is supported through Edge Bridge and Edge Network extensions.

MobileCore.trackState("myState",  data: {"key1": "value1"});

Identity

For more information on the Core Identity APIs, visit the documentation here.

Importing Identity:
import 'package:flutter_aepcore/flutter_aepidentity.dart';
Getting Identity version:
String version = await Identity.extensionVersion;
Sync Identifier:
Identity.syncIdentifier("identifierType", "identifier", MobileVisitorAuthenticationState.authenticated);
Sync Identifiers:
Identity.syncIdentifiers({"idType1":"idValue1",
                                    "idType2":"idValue2",
                                    "idType3":"idValue3"});
Sync Identifiers with Authentication State:
Identity.syncIdentifiersWithAuthState({"idType1":"idValue1", "idType2":"idValue2", "idType3":"idValue3"}, MobileVisitorAuthenticationState.authenticated);

Note: MobileVisitorAuthenticationState is defined as:

enum MobileVisitorAuthenticationState {unknown, authenticated, logged_out}
Append visitor data to a URL:
String result = "";

try {
  result = await Identity.appendToUrl("www.myUrl.com");
} on PlatformException {
  log("Failed to append URL");
}
Setting the advertising identifier:
MobileCore.setAdvertisingIdentifier("ad-id");
Get visitor data as URL query parameter string:
String result = "";

try {
  result = await Identity.urlVariables;
} on PlatformException {
  log("Failed to get url variables");
}
Get Identifiers:
List<Identifiable> result;

try {
  result = await Identity.identifiers;
} on PlatformException {
  log("Failed to get identifiers");
}
Get Experience Cloud IDs:
String result = "";

try {
  result = await Identity.experienceCloudId;
} on PlatformException {
  log("Failed to get experienceCloudId");
}
AEPMobileVisitorId Class:
class Identifiable {
  String get idOrigin;
  String get idType;
  String get identifier;
  MobileVisitorAuthenticationState get authenticationState;
}

Lifecycle

For more information on the Core Lifecycle APIs, visit the documentation here

Note: It is required to implement Lifecycle in native Android and iOS code.

Signal

For more information on the Core Signal APIs, visit the documentation here

Importing Signal:
import 'package:flutter_aepcore/flutter_aepsignal.dart';
Getting Signal version:
String version = await Signal.extensionVersion;

Tests

Run:

$ cd plugins/flutter_{plugin_name}/
$ flutter test

Contributing

See CONTRIBUTING

License

See LICENSE