0 purchases
flutter aepmessaging
flutter_aepmessaging #
flutter_aepmessaging is a flutter plugin for the iOS and Android AEPMessaging SDK to allow for integration with Flutter applications. Functionality to enable the Messaging extension is provided entirely through Dart documented below.
Prerequisites #
The Adobe Experience Platform Messaging extension has the following peer dependency, which must be installed prior to installing it:
flutter_aepcore
flutter_aepedge
flutter_aepedgeidentity
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
copied to clipboard
Usage #
For more detailed information on the Messaging 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;
@import AEPMessaging;
...
@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 = @[AEPMessaging.class,
AEPMobileEdge.class,
AEPMobileEdgeIdentity.class
];
[AEPMobileCore registerExtensions:extensionsToRegister completion:^{
[AEPMobileCore configureWithAppId: ENVIRONMENT_FILE_ID];
}];
return YES;
}
copied to clipboard
Android
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Edge;
import com.adobe.marketing.mobile.messaging.Messaging;
...
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 onCreate() {
super.onCreate();
List<Class<? extends Extension>> extensions = Arrays.asList(
Edge.EXTENSION,
EdgeIdentity.EXTENSION,
Messaging.EXTENSION
);
MobileCore.registerExtensions(extensions, o -> MobileCore.configureWithAppID(ENVIRONMENT_FILE_ID));
}
}
copied to clipboard
Importing the extension #
In your Flutter application, import the Messaging extension as follows:
import 'package:flutter_aepmessaging/flutter_aepmessaging.dart';
copied to clipboard
API reference #
extensionVersion #
Returns the SDK version of the Messaging extension.
Syntax
static Future<String> get extensionVersion
copied to clipboard
Example
String version = await Messaging.extensionVersion;
copied to clipboard
getCachedMessages #
Returns a list of messages that have currently been cached in-memory using Messaging.saveMessage()
Syntax
List<Message> messages = await Messaging.getCachedMessages();
copied to clipboard
refreshInAppMessages #
This API retrieves the Experience Cloud ID (ECID) that was generated when the app was initially launched. This ID is preserved between app upgrades, is saved and restored during the standard application backup process, and is removed at uninstall.
Syntax
static Future<void> refreshInAppMessages
copied to clipboard
Example
await Messaging.refreshInAppMessages();
copied to clipboard
Handling In App Messages using Message Object #
Note: In order to use the methods defined in the Message class, use getCachedMessages to retrieve the messages that have been cached in-memory, and then use the Message objects returned.
The Message object passed to the MessagingDelegate contains the following functions to handle a message:
show #
Signals to the UIService that the message should be displayed.
Syntax
show()
copied to clipboard
Example
Message message
message.show()
copied to clipboard
dismiss #
Signals to the UIService that the message should be dismissed.
Syntax
dismiss(((suppressAutoTrack: ?boolean) = false))
copied to clipboard
Example
Message message
message.dismiss(true)
copied to clipboard
track #
Generates an Edge Event for the provided interaction and event type.
Syntax
track(String interaction, MessagingEdgeEventType eventType)
copied to clipboard
Example
Message message;
message.track("sample text", MessagingEdgeEventType.IN_APP_DISMISS)
copied to clipboard
setAutoTrack #
Enables/Disables auto-tracking for message events.
Syntax
setAutoTrack(Bool autoTrack)
copied to clipboard
Example
Message message;
message.setAutoTrack(true)
copied to clipboard
clear #
Clears the reference to the in-memory cached Message object. This function must be called if a message was saved by calling shouldSaveMessage but no longer needed. Failure to call this function leads to memory leaks.
Syntax
clear()
copied to clipboard
Example
Message message
message.clear()
copied to clipboard
Push Notification Setup #
Handling push notifications must be done in native (Android/iOS) code for the Flutter app. To configure push notifications in the native project, follow the instructions provided for their respective platforms:
Apple - iOS push notification setup
Google - Android push notification setup
Push Messaging APIs usage #
The AEPMessaging extension's push messaging APIs must be called from the native Android/iOS project of Flutter app.
iOS API usage
Android API usage
In Android, MessagingPushPayload can be used for getting the notification attributes like title, body, and action. These are useful for push notification creation.
Contributing #
See CONTRIBUTING
License #
See LICENSE
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.