Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 30 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,60 +27,59 @@ This repository is a monorepo. It contains a collection of Adobe Experience Plat

First, make sure that `Flutter` is [installed](https://docs.flutter.dev/get-started/install).

Now to install the package, run:
### Installing using Terminal:

Install the package, run:

```bash
cd MyFlutterApp
flutter pub add flutter_{plugin_name}
```

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):
This will automatically update your package's pubspec.yaml with the dependency, and run an implicit `flutter pub get`.

### Installing Manually:

Alternatively, Editing pubspec.yaml manually with dependencies.

```
dependencies:
flutter_{plugin_name}: ^{latest_version}
```

Now import the plugin in your Dart code as follows:
Run:

```
import 'package:flutter_{extension}/flutter_{plugin_name}.dart'
flutter pub get
```

Install instructions for each respective plugin can be found in each plugin's readme: `/plugins/{plugin_name}/README.md`. Start by installing `flutter_aepcore` which is a dependency for all other extensions.

## 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](https://developer.adobe.com/client-sdks/documentation/getting-started/get-the-sdk/#2-add-initialization-code). The linked documentation initalizes the User Profile extension which is not required or supported in Flutter.

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

#### iOS:
For iOS development, after installing the plugin packages, download the pod dependencies by running the following command to link the libraries to your Xcode project :

Add the initialization code in [AppDelegate.m or AppDelegate.swift](/example/ios/Runner/AppDelegate.m#L9) file of the generated iOS project.
```bash
cd ios && pod install && cd ..
```
To update native dependencies to latest available versions, run the following command:

#### Android:
Create an [Application class](/example/android/app/src/main/java/com/adobe/marketing/mobile/flutter/flutter_aepsdk_example/MyApplication.java) which extends [FlutterApplication](https://api.flutter.dev/javadoc/io/flutter/app/FlutterApplication.html) and add the initialization code. Change your [AndroidManifest.xml](/example/android/app/src/main/AndroidManifest.xml#L9) to reference this new class.
```bash
cd ios && pod update && cd ..
```
## Importing the Plugin

Once you have added the initialization code to your app, be sure to set the SDK wrapper type to Flutter before you start the SDK.
For both installation methods, you need to import the package in your **Dart** code as follows:

###### iOS:
Swift:
```swift
MobileCore.setWrapperType(.flutter)
```

Objective-C:
```objective-c
[AEPMobileCore setWrapperType:AEPWrapperTypeFlutter];
import 'package:flutter_{extension}/flutter_{plugin_name}.dart'
```

###### Android:
```java
MobileCore.setWrapperType(WrapperType.FLUTTER);
```
## Initializing

Then, initialize the SDK using the following methods:
- [MobileCore.initializeWithAppId(appId)](https://github.com/adobe/aepsdk_flutter/tree/main/plugins/flutter_aepcore#initializewithappid)
- [MobileCore.initialize(initOptions)](https://github.com/adobe/aepsdk_flutter/tree/main/plugins/flutter_aepcore#initialize)

> [!NOTE]
> Starting from Adobe Experience Platform Flutter **5.x**, there is no longer a need to initialize the SDK on the [native platforms](https://github.com/adobe/aepsdk_flutter/tree/v4.x?tab=readme-ov-file#usage), as was required in earlier versions.

## Tests

Expand Down
156 changes: 37 additions & 119 deletions docs/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Update your `pubspec.yml` file to point to the new plugin as so:

dependencies:
- flutter_acpcore: ^2.0.0
+ flutter_aepcore: ^4.0.0
+ flutter_aepcore: ^5.0.0

...
```
Expand All @@ -27,135 +27,53 @@ Updated plugins can be found in this repository under [plugins/](https://github.
| Place Services| NA |
| Place Monitor | NA |

## Update SDK initialization

Remove the deprecated registration code and the extensions that are not supported in AEP Flutter libraries.

### Android
## Update import plugins
```diff
import com.adobe.marketing.mobile.AdobeCallback;
import com.adobe.marketing.mobile.Identity;
import com.adobe.marketing.mobile.InvalidInitException;
import com.adobe.marketing.mobile.Lifecycle;
import com.adobe.marketing.mobile.LoggingMode;
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Signal;
import com.adobe.marketing.mobile.Assurance;
import com.adobe.marketing.mobile.UserProfile;
...
import android.app.Application;
import io.flutter.app.FlutterApplication;
...
public class MyApplication extends FlutterApplication {
...
@Override
public void on Create(){
super.onCreate();
...
MobileCore.setApplication(this);
MobileCore.setLogLevel(LoggingMode.DEBUG);
MobileCore.setWrapperType(WrapperType.FLUTTER);

- try {
- Identity.registerExtension();
- Lifecycle.registerExtension();
- Signal.registerExtension();
- Assurance.registerExtension();
- UserProfile.registerExtension();
- Analytics.registerExtension();
- Places.registerExtension();
- MobileCore.start(new AdobeCallback () {
- @Override
- public void call(Object o) {
- MobileCore.configureWithAppID("yourAppID");
- }
- });
- } catch (InvalidInitException e) {

List<Class<? extends Extension>> extensions = Arrays.asList(
Identity.EXTENSION,
Lifecycle.EXTENSION,
Signal.EXTENSION,
Assurance.EXTENSION,
UserProfile.EXTENSION
);
MobileCore.registerExtensions(extensions, o -> MobileCore.configureWithAppID("YourEnvironmentFileID"));
...
}
}
}
- import 'package:flutter_acpcore/flutter_acpcore.dart';
+ import 'package:flutter_aepcore/flutter_aepcore.dart';
```

### iOS

> Note: For iOS app, after installing the AEP-prefixed packages, please update native dependecies by running the following command: `cd ios && pod update && cd ..`

```objectivec

// 1. remove the following header files
//#import "ACPCore.h"
//#import "ACPUserProfile.h"
//#import "ACPIdentity.h"
//#import "ACPLifecycle.h"
//#import "ACPSignal.h"
## Update SDK initialization

// 2. import AEP extensions
@import AEPCore;
@import AEPUserProfile;
@import AEPLifecycle;
@import AEPIdentity;
@import AEPServices;
@import AEPSignal;
@import AEPAssurance;
// --- 2. end ----
> [!NOTE]
> Starting from Adobe Experience Platform Flutter **5.x**, there is no longer a need to initialize the SDK on the [native platforms](https://github.com/adobe/aepsdk_flutter/tree/v4.x?tab=readme-ov-file#usage), as was required in earlier versions.

...
@implementation AppDelegate
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// 3. remove the following code for initializing ACP SDKs

// [ACPCore setLogLevel:ACPMobileLogLevelDebug];
// [ACPCore configureWithAppId:@"yourAppID"];
// [ACPUserProfile registerExtension];
// [ACPIdentity registerExtension];
// [ACPLifecycle registerExtension];
// [ACPSignal registerExtension];
// [ACPAnalytics registerExtension];

// const UIApplicationState appState = application.applicationState;
// [ACPCore start:^{
// if (appState != UIApplicationStateBackground) {
// [ACPCore lifecycleStart:nil];
// }
// }];

// 4. add code to initializing AEP SDKs

[AEPMobileCore setLogLevel: AEPLogLevelDebug];
[AEPMobileCore configureWithAppId:@"yourAppID"];

const UIApplicationState appState = application.applicationState;

[AEPMobileCore registerExtensions: @[
AEPMobileLifecycle.class,
AEPMobileSignal.class,
AEPMobileIdentity.class,
AEPMobileUserProfile.class,
AEPMobileAssurance.class,
] completion:^{
if (appState != UIApplicationStateBackground) {
[AEPMobileCore lifecycleStart:nil}];
}
}];
// --- 4. end ----

...
return YES;
}
Remove all the ACP registration code and the extensions code on the native `Android` and `iOS` platforms.

Initialize AEP SDK in the **Dart** application:

**Example**

```dart
class _HomePageState extends State<HomePage> {
/// Initialize the Adobe Experience Platform Mobile SDK inside the initState method.
@override
void initState() {
super.initState();
_initializeAEPMobileSdk();
}

Future<void> _initializeAEPMobileSdk() async {
MobileCore.setLogLevel(LogLevel.trace);
MobileCore.initializeWithAppId(appId:"YOUR_APP_ID");

// For more granular control over the initial options, you can use the following sample code:
// InitOptions initOptions = InitOptions(
// appId: "YOUR_APP_ID",
// lifecycleAutomaticTrackingEnabled: true,
// lifecycleAdditionalContextData: {"key": "value"},
// appGroupIOS: "group.com.example",
// );

@end
// MobileCore.initialize(initOptions: initOptions);
}
```

Refer to the initializing details info [here](https://github.com/adobe/aepsdk_flutter/tree/main?tab=readme-ov-file#initializing).

## Update API usage and references for each extension

### Core
Expand Down
6 changes: 2 additions & 4 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ A few resources to get you started if this is your first Flutter project:
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

For help getting started with Flutter, view our
For help getting started with Flutter, view the
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.


## How to run the example app:

### Add your App Id:
In `ios/Runner/AppDelegate.m`, find the call to `configureWithAppId` and add your app id.

In `android/**/MyApplication.java`, find the call to `configureWithAppId` and add your app id.
In `lib/main.dart`, locate the call to `MobileCore.initializeWithAppId(appId:"YOUR_APP_ID")` and replace `"YOUR_APP_ID"` with your property App Id.

#### Run instructions for Android:

Expand Down
14 changes: 6 additions & 8 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
Expand All @@ -6,11 +12,6 @@ if (localPropertiesFile.exists()) {
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
Expand All @@ -21,9 +22,6 @@ if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdk 34
namespace 'com.adobe.marketing.mobile.flutter.flutter_aepsdk_example'
Expand Down
2 changes: 0 additions & 2 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name=".MyApplication"
android:label="flutter_aepsdk_example"
android:icon="@mipmap/ic_launcher">
<activity
Expand Down Expand Up @@ -36,7 +35,6 @@
android:host="adobe" />
</intent-filter>
</activity>

<meta-data
android:name="flutterEmbedding"
android:value="2" />
Expand Down
Loading