flutter_aepedge 3.0.0 copy "flutter_aepedge: ^3.0.0" to clipboard
flutter_aepedge: ^3.0.0 copied to clipboard

Official Adobe Experience Platform support for Flutter apps. The Experience Platform Edge extension enables sending data to the Adobe Experience Edge from a mobile device.

flutter_aepedge #

pub package Build License

flutter_aepedge is a flutter plugin for the iOS and Android Adobe Experience Platform Edge SDK to allow for integration with Flutter applications. Functionality to enable the Edge extension is provided entirely through Dart documented below.

Prerequisites #

The Edge Network extension has the following peer dependencies, which must be installed prior to installing it:

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.

Tests #

Run:

flutter test

Usage #

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

Registering the extension with AEPCore: #

Note: It is required to initialize the SDK via native code inside your AppDelegate (iOS) and MainApplication class (Android).

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.

Initialization Example

iOS

// AppDelegate.h
@import AEPCore;
@import AEPEdge;
@import AEPEdgeIdentity;
...
@implementation AppDelegate

// AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [AEPMobileCore setWrapperType:AEPWrapperTypeFlutter];

     // TODO: Set up the preferred Environment File ID from your mobile property configured in Data Collection UI
    NSString* ENVIRONMENT_FILE_ID = @"YOUR-APP-ID";
    
    NSArray *extensionsToRegister = @[AEPMobileEdgeIdentity.class, 
                                      AEPMobileEdge.class                                             
                                      ];

    [AEPMobileCore registerExtensions:extensionsToRegister completion:^{
    [AEPMobileCore configureWithAppId: ENVIRONMENT_FILE_ID];
    }];
    return YES;   
 } 

Android

import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Edge;
import com.adobe.marketing.mobile.edge.identity.Identity;  
...
import io.flutter.app.FlutterApplication;
...
public class MainApplication extends FlutterApplication {
  ...
  // TODO: Set up the preferred Environment File ID from your mobile property configured in Data Collection UI
  private final String ENVIRONMENT_FILE_ID = "YOUR-APP-ID";

  @Override
  public void on Create(){
    super.onCreate();
    ...
    MobileCore.setApplication(this);
    MobileCore.setWrapperType(WrapperType.FLUTTER);
    MobileCore.configureWithAppID(ENVIRONMENT_FILE_ID);

    MobileCore.registerExtensions(
        Arrays.asList(Edge.EXTENSION, Identity.EXTENSION),
        o -> Log.d("MainApp", "Adobe Experience Platform Mobile SDK was initialized.")
    );
  }
}

Importing the extension #

In your Flutter application, import the Edge extension as follows:

import 'package:flutter_aepedge/flutter_aepedge.dart';

API reference #

extensionVersion #

Returns the SDK version of the Edge Network extension.

Syntax

static Future<String> get extensionVersion

Example

String version = await Edge.extensionVersion;

getLocationHint #

Gets the Edge Network location hint used in requests to the Adobe Experience Platform Edge Network. The Edge Network location hint may be used when building the URL for Adobe Experience Platform Edge Network requests to hint at the server cluster to use.

Syntax

static Future<String?> get locationHint

Example

String? result = null;

try {
  result = await Edge.locationHint;
} on PlatformException {
  log("Failed to get location hint");
}

resetIdentity #

Resets current state of the AEP Edge extension and clears previously cached content related to current identity, if any. See MobileCore.resetIdentities for more details.


setLocationHint #

Sets the Edge Network location hint used in requests to the Adobe Experience Platform Edge Network. Passing null or an empty string clears the existing location hint. Edge Network responses may overwrite the location hint to a new value when necessary to manage network traffic.

Warning: Use caution when setting the location hint. Only use location hints for the "EdgeNetwork" scope. An incorrect location hint value will cause all Edge Network requests to fail with 404 response code.

Syntax

static Future<void> setLocationHint([String? hint])

Example

Edge.setLocationHint('va6');

sendEvent #

Sends an Experience event to Adobe Experience Platform Edge Network.

Syntax

static Future<List<EventHandle>> sendEvent(
    ExperienceEvent experienceEvent,
  )

Example

Map<String, dynamic> xdmData = {"eventType": "SampleEventType"};
Map<String, dynamic> data = {"free": "form", "data": "example"};
final ExperienceEvent experienceEvent = ExperienceEvent({
  "xdmData": xdmData,
  "data": data
});
List<EventHandle> result = await Edge.sendEvent(experienceEvent);

Public classes #

ExperienceEvent

Experience Event is the event to be sent to Adobe Experience Platform Edge Network. The XDM data is required for any Experience Event being sent using the Edge extension.

Create Experience Event from Dictionary:
Map<String, dynamic> xdmData = {"eventType": "SampleEventType"};
final ExperienceEvent experienceEvent = ExperienceEvent({
  "xdmData": xdmData
});
Add free form data to the Experience event:
Map<String, dynamic> xdmData = {"eventType": "SampleEventType"};
Map<String, dynamic> data = {"free": "form", "data": "example"};
final ExperienceEvent experienceEvent = ExperienceEvent({
  "xdmData": xdmData,
  "data": data
});
Set the destination Dataset identifier to the current Experience event:
Map<String, dynamic> xdmData = {"eventType": "SampleEventType"};
final ExperienceEvent experienceevent = ExperienceEvent({
  "xdmData": xdmData,
  "data": null,
  "datasetIdentifier": "datasetIdExample"
});
Create Experience Event with xdmdata, free form data and the destination Dataset identifier:
Map<String, dynamic> xdmData = {"eventType": "SampleEventType"};
Map<String, dynamic> data = {"free": "form", "data": "example"};

final ExperienceEvent experienceEvent = ExperienceEvent({
  "xdmData": xdmData,
  "data": data,
  "datasetIdentifier": "datasetIdExample"
});

EventHandle

The EventHandle is a response fragment from Adobe Experience Platform Edge Network for a sent XDM Experience Event. One event can receive none, one or multiple EdgeEventHandle(s) as a response.

static const String _type = 'type';
static const String _payload = 'payload';

Contributing #

See CONTRIBUTING

License #

See LICENSE

1
likes
120
pub points
91%
popularity

Publisher

verified publisheradobe.com

Official Adobe Experience Platform support for Flutter apps. The Experience Platform Edge extension enables sending data to the Adobe Experience Edge from a mobile device.

Homepage
Repository (GitHub)
View/report issues
Contributing

Documentation

API reference

License

Apache-2.0 (LICENSE)

Dependencies

flutter, flutter_aepcore, flutter_aepedgeidentity

More

Packages that depend on flutter_aepedge