Skip to content

Commit

Permalink
Migration guide for version 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
roland-misica authored Dec 12, 2024
1 parent 60153eb commit cd02f5a
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Documentation/version-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,58 @@ parentDocSlug: flutter-sdk-release-notes

This guide will help you upgrade your Exponea SDK to the new version.

## Update from version 1.x.x to 2.x.x

Updating the Exponea Flutter SDK to version 2.X.X from 1.X.X requires making some changes related to in-app messages Action Stream implementations.

The inAppMessageActionStream was changed and simplified, so you have to migrate your implementation of in-app message action and close handling. This migration requires changing decision logic based on parameters coming from the stream.

Your implementation may have been similar to the following example:

```dart
const overrideDefaultBehavior = false;
const trackActions = false;
final subscription = _plugin.inAppMessageActionStream(overrideDefaultBehavior: overrideDefaultBehavior, trackActions: trackActions).listen((inAppMessageAction) {
if (inAppMessageAction.button != null) {
_plugin.trackInAppMessageClick(inAppMessageAction.message, inAppMessageAction.button);
} else {
_plugin.trackInAppMessageClose(inAppMessageAction.message, interaction: inAppMessageAction.interaction);
}
});
```

To update to version 2 of the SDK, you must recognize the inAppMessageAction event by its `type` parameter and refactor your code as follows:

```dart
const overrideDefaultBehavior = false;
const trackActions = false;
final subscription = _plugin.inAppMessageActionStream(overrideDefaultBehavior: overrideDefaultBehavior, trackActions: trackActions).listen((inAppMessageAction) {
if (<your-special-condition>) {
switch(inAppMessageAction.type) {
case InAppMessageActionType.click:
_plugin.trackInAppMessageClick(inAppMessageAction.message!, inAppMessageAction.button!);
break;
case InAppMessageActionType.close:
_plugin.trackInAppMessageClose(inAppMessageAction.message!, button: inAppMessageAction.button, interaction: inAppMessageAction.interaction ?? true);
break;
case InAppMessageActionType.error:
// Here goes your code
break;
case InAppMessageActionType.show:
// Here goes your code
break;
}
}
});
```

A benefit of the new behavior is that the method inAppMessageCloseAction can be called with a non-null button parameter. This happens when a user clicks on the Cancel button and enables you to determine which button has been clicked by reading the button text.

### inAppMessageAction scheme change

inAppMessageActionStream also emits Show and Error events. You can distinguish events by introduced `type` parameter in `inAppMessageAction`.
As not all values are reported for each type, `interaction` and `InAppMessage` in scheme become nullable.

## Update from version 0.x.x to 1.x.x

Updating the Exponea Flutter SDK to version 1 and higher requires making some changes related to Firebase push notifications.
Expand Down

0 comments on commit cd02f5a

Please sign in to comment.