Flutter Embedded Content
Embedded Content is an alternative Scene format that can be displayed on any app or web screen in a view defined by a developer. It can also be presented in Story format. Flutter Module 7.8.0+
About Embedded Content
Present the content of a SceneA single or multi-screen in-app experience cached on users’ devices and displayed when users meet certain conditions in your app or website, such as viewing a particular screen or when a Custom Event occurs. They can be presented in fullscreen, modal, or embedded format using the default swipe/click mode or as a Story. Scenes can also contain survey questions. on any app screen. There are three primary components:
Component | Description |
---|---|
A "view" in your app where the content will display | An app developer creates an AirshipEmbeddedView that controls the dimensions of the content and its location in your app. They also determine what content can be displayed in the view by setting a value for the view's embeddedId that matches the ID of an Embedded Content view style. |
A view style in your project settings | A marketer creates an Embedded Content view style and assigns an ID for reference in the app view's embeddedId . |
A Scene using an Embedded Content view style | This is the source of the content that will be displayed in the view. |
Once the Scene is triggered for display and matches the specified audience conditions, its content is available to users when visiting a screen that contains the AirshipEmbeddedView
.
The view is populated with the content from all active Scenes with the matching ID, sorted based on priority. When an embedded view loads content, the highest priority Scene that is queued for display will be shown. The same content will be shown across app and web sessions until it is dismissed by the user or is no longer available. The view will then show the next Scene with the highest priority from the display queue.
Airship first prepares the content when the triggering event occurs and then refreshes it upon every app open or web session start. This ensures that users always experience the most up-to-date message. So, after updating active Embedded Content, users will see the latest version the next time they open the app or load the app or web page containing the view.
Embedded Content behavior is the same as In-App AutomationsMessages cached on users’ devices and displayed when users meet certain conditions within your app, such as viewing a particular screen or opening the app a certain number of times. and modal and fullscreen Scenes:
- The content displays only within the app.
- When the app is terminated, the content is not automatically dismissed. It continues to display in the next app session.
Adding an AirshipEmbeddedView
The AirshipEmbeddedView
is a Flutter widget that defines a place for Airship Embedded Content to be displayed. When defining an AirshipEmbeddedView
, specify the embeddedId
for the content it should display. The value of the embeddedId
must be the ID of an Embedded Content view style in your project.
// Show any "home_banner" Embedded Content
AirshipEmbeddedView(
embeddedId: "home_banner"
)
Observing available Embedded Content
Embedded Content is not always available, and even after being triggered, it still needs to be prepared before it can be displayed. An AirshipEmbeddedView
will automatically render once the content is available. When no content is available, it
will render as an empty view. You can query for when content is available to either show a placeholder or to remove the embedded view.
// Check if any "home_banner" Embedded Content is available
bool isAvailable = Airship.inApp.isEmbeddedAvailable(embeddedId: "home_banner");
// handle isAvailable
Airship.inApp.isEmbeddedAvailableStream(embeddedId: "home_banner")
.listen((isAvailable) {
// handle isAvailable
});
Example Integration
Here is an example integration that renders an Embedded Content when available, and displays an image placeholder when unavailable:
import 'package:flutter/material.dart';
import 'package:airship_flutter/airship_flutter.dart';
class HomeScreen extends StatefulWidget {
@override
_HomeScreenState createState() => _HomeScreenState();
}
class _HomeScreenState extends State<HomeScreen> {
bool _isHomeBannerAvailable = false;
@override
void initState() {
super.initState();
_setupEmbeddedContentListener();
}
void _setupEmbeddedContentListener() {
Airship.inApp.isEmbeddedAvailableStream(embeddedId: "home_banner")
.listen((isAvailable) {
setState(() {
_isHomeBannerAvailable = isAvailable;
});
});
}
@override
Widget build(BuildContext context) {
return Container(
child: _isHomeBannerAvailable
? AirshipEmbeddedView(
embeddedId: "home_banner"
)
: Image.asset(
'assets/images/airship-mark.png',
fit: BoxFit.contain,
width: double.infinity,
height: 200,
),
);
}
}
Categories