Effective marketing automation is an essential part of successfully scaling and managing your business.
This project contains the Braze plug-in package, a specialized package that allows integrators to use certain Braze APIs from Flutter app code written in Dart.
-
Follow the directions in the Install Tab to import Braze into your project.
-
Instantiate an instance of the Braze plugin by calling
new BrazePlugin()
-
In your
res/values
directory, create a file calledbraze.xml
and add your API key and set your custom endpoint as specified in our public documentation. -
Add required permissions to your
AndroidManifest
, as specified in our public documentation. -
To integrate push, follow the directions in our public documentation. Note that only registration using our "automatic FCM registration" is currently supported from Flutter apps.
-
Call
registerActivityLifecycleCallbacks(AppboyLifecycleCallbackListener())
in yourApplication
subclass'sonCreate()
method to automatically register for session tracking and in-app message display. If you do not have anApplication
subclass, add the call to theonCreate()
method of your mainActivity
.
-
Call
Appboy.startWithApiKey()
in yourAppDelegate
'sdidFinishLaunchingWithOptions
delegate method as specified in our public documentation. -
Set your custom endpoint as specified in our public documentation. We recommend the
Info.plist
approach.
Native in-app messages display automatically out of the box on Android and iOS.
To disable automatic in-app message display for Android, implement the IInAppMessageManagerListener
delegate as described in our public documentation. Your beforeInAppMessageDisplayed
method implementation should return InAppMessageOperation.DISCARD
. For an example, see MainActivity.kt
in our example app.
To disable automatic in-app message display for iOS, implement the ABKInAppMessageControllerDelegate
delegate as described in our public documentation. Your beforeInAppMessageDisplayed
delegate implementation should return ABKInAppMessageDisplayChoice.discardInAppMessage
. For an example, see AppDelegate.swift
in our example app.
You may set a callback in Dart to receive Braze in-app message data in the Flutter host app.
To set the callback, call BrazePlugin.setBrazeInAppMessageCallback()
from your Flutter app with a function that takes a BrazeInAppMessage
instance. The BrazeInAppMessage
object supports a subset of fields available in the native model objects, including uri
, message
, header
, buttons
, extras
, and more.
On Android, you will additionally need to implement the IInAppMessageManagerListener
delegate as described in our public documentation. Your beforeInAppMessageDisplayed()
method implementation must call BrazePlugin.process(inAppMessage)
. For an example, see MainActivity.kt
in our example app.
On iOS, you will additionally need to implement the ABKInAppMessageControllerDelegate
delegate as described in our public documentation. Your beforeInAppMessageDisplayed
delegate implementation must call BrazePlugin.process(inAppMessage)
. For an example, see AppDelegate.swift
in our example app.
To log analytics using your BrazeInAppMessage
, pass the instance into the logInAppMessageClicked
, logInAppMessageImpression
, and logInAppMessageButtonClicked
methods available on the main plugin interface.
You may set a callback in Dart to receive Braze Content Card data in the Flutter host app.
To set the callback, call BrazePlugin.setBrazeContentCardsCallback()
from your Flutter app with a function that takes a List<BrazeContentCard>
instance. The BrazeContentCard
object supports a subset of fields available in the native model objects, including description
, title
, image
, url
, extras
, and more.
On Android, you will additionally need to implement and register an IEventSubscriber<ContentCardsUpdatedEvent>
as described in our public documentation. Your trigger()
method implementation must call BrazePlugin.processContentCards(event.allCards)
. For an example, see MainActivity.kt
in our example app.
On iOS, you will additionally need to create an NSNotificationCenter
listener for ABKContentCardsProcessedNotification
events as described in our public documentation. Your ABKContentCardsProcessedNotification
callback implementation must call BrazePlugin.processContentCards(contentCards)
. For an example, see AppDelegate.swift
in our example app.
To log analytics using your BrazeContentCard
, pass the instance into the logContentCardClicked
, logContentCardImpression
, and logContentCardDismissed
methods available on the main plugin interface.