Skip to content
Open
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
25 changes: 25 additions & 0 deletions docs/in-app-messaging/_customize-messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,28 @@ The action's format depends on which message layout you choose. Modals get
action buttons with customizable button text content, text color, and background
color. Images and top banners, on the other hand, become interactive and invoke
the specified action when tapped.

## Render campaigns with Flutter widgets

By default, In-App Messaging draws native templates (banner, modal, card,
image-only). To render campaigns with your own Flutter UI instead, opt in to
custom display, listen for the campaign payload, and report impression, click,
and dismiss back to the SDK:

```dart
FirebaseInAppMessaging.instance.onMessageDisplay.listen((message) async {
await message.impress();
// Draw your own widgets using message.title, body, imageUrl, actions, data.
// The plugin does not open action URLs — your app should.
await message.click(message.primaryAction ?? message.action!);
await message.dismiss();
});

await FirebaseInAppMessaging.instance.setCustomDisplayEnabled(true);
```

Until `setCustomDisplayEnabled(true)` is called, native templates keep working.
Listening to `onMessageDisplay` alone does not replace native UI.

If you also listen to `onMessageClicked` / `onMessageImpression`, those
lifecycle streams still fire when your Flutter UI reports click and impress.
5 changes: 2 additions & 3 deletions docs/in-app-messaging/_modify-message-behavior.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ In your campaigns, you can specify custom data in a series of key/value pairs.
When users interact with messages, this data is available for you to, for example,
display a promo code.

To do so, you will have to use the platform-native APIs.
See the documentation for [iOS](/docs/in-app-messaging/modify-message-behavior?platform=ios#use_campaign_custom_metadata)
and [Android](/docs/in-app-messaging/modify-message-behavior?platform=android#use_campaign_custom_metadata).
When you opt in to [custom Flutter display](/docs/in-app-messaging/customize-messages?platform=flutter),
those key/value pairs are available on `InAppMessage.data`.


## Temporarily disable in-app messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ FirebaseInAppMessaging.instance.onMessageClicked.listen((event) {
`onMessageImpression`, `onMessageDismissed` and `onMessageDisplayError` report
the rest of the message lifecycle.

### Custom Flutter display

To render campaigns with your own widgets instead of the native templates:

```dart
FirebaseInAppMessaging.instance.onMessageDisplay.listen((message) async {
await message.impress();
// Draw your own UI, then:
// await message.click(message.action!);
// await message.dismiss();
});

await FirebaseInAppMessaging.instance.setCustomDisplayEnabled(true);
```

The plugin does not open action URLs. You must report impress / click / dismiss
so campaign analytics keep working.

## Issues and feedback

Please file FlutterFire specific issues, bugs, or feature requests in our [issue tracker](https://github.com/firebase/flutterfire/issues/new).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ android {
dependencies {
api firebaseCoreProject
implementation platform("com.google.firebase:firebase-bom:${getRootProjectExtOrCoreProperty("FirebaseSDKVersion", firebaseCoreProject)}")
implementation 'com.google.firebase:firebase-inappmessaging-display'
// `api` so app Java compilation can resolve FirebaseInAppMessagingDisplay,
// which the plugin class implements.
api 'com.google.firebase:firebase-inappmessaging'
api 'com.google.firebase:firebase-inappmessaging-display'
implementation 'androidx.annotation:annotation:1.7.0'
}
}
Expand Down
Loading
Loading