Modify behavior of Firebase In-App Messaging messagesStay organized with collectionsSave and categorize content based on your preferences.
With little to no coding effort, Firebase In-App Messaging allows you to create,
configure and target rich user interactions, leveraging
the capabilities ofGoogle Analyticsout of the box
to tie messaging events to actual user characteristics, activities, and choices.
With some additionalFirebase In-App MessagingSDK integration, you can tailor
the behavior of in-app messages even further, responding when users interact
with messages, triggering message events outside theAnalyticsframework, and allowing users to control sharing of their personal data related
to messaging interactions.
Respond when users interact with in-app messages
With actions you can use your in-app messages to direct users to a
website or a specific screen in your app.
Your code can respond to basic interactions (clicks and dismissals), to
impressions (verified views of your messages), and to display errors logged and
confirmed by the SDK. For example, when your message is composed as a Card
modal, you might want to track and follow-up on which of two URLs the user
clicked on the Card.
Implement a DisplayDelegate to handle Card interactions
You can register an in-app messaging display delegate that will be called
whenever there is any interaction with an in-app message. To do this, implement
a class per theInAppMessagingDisplayDelegateprotocol and set it as the
delegate property on theInAppMessaginginstance.
Assuming again that you want to track which link a user clicked on a Card-style
message, define a class that implements themessageClickedmethod per theDisplayDelegateprotocol, thereby providing you access to the
link clicked by the user.
Swift
Note:This product is not available on macOS, Mac Catalyst, App Clip or watchOS targets.
Refer to the Swiftdisplay delegate referencefor the set of callback methods that can be implemented and their parameters, including
InAppMessagingAction.
// In CardActionFiamDelegate.swiftclassCardActionFiamDelegate:NSObject,InAppMessagingDisplayDelegate{funcmessageClicked(_inAppMessage:InAppMessagingDisplayMessage){// ...}funcmessageDismissed(_inAppMessage:InAppMessagingDisplayMessage,dismissType:InAppMessagingDismissType){// ...}funcimpressionDetected(forinAppMessage:InAppMessagingDisplayMessage){// ...}funcdisplayError(forinAppMessage:InAppMessagingDisplayMessage,error:Error){// ...}}
// In AppDelegate.swift// Register the delegate with the InAppMessaging instanceletmyFiamDelegate=CardActionFiamDelegate()InAppMessaging.inAppMessaging().delegate=myFiamDelegate;
Note:This product is not available on macOS, Mac Catalyst, App Clip or watchOS targets.
Refer to the Objective-Cdisplay delegate referencefor the set of callback methods that can be implemented and their parameters, including
FIRInAppMessagingDisplayMessage.
// In CardActionFiamDelegate.h@interfaceCardActionFiamDelegate:NSObject<FIRInAppMessagingDisplayDelegate>@end// In CardActionFiamDelegate.m@implementationCardActionFiamDelegate-(void)displayErrorForMessage:(nonnullFIRInAppMessagingDisplayMessage*)inAppMessageerror:(nonnullNSError*)error{// ...}-(void)impressionDetectedForMessage:(nonnullFIRInAppMessagingDisplayMessage*)inAppMessage{// ...}-(void)messageClicked:(nonnullFIRInAppMessagingDisplayMessage*)inAppMessage{// ...}-(void)messageDismissed:(nonnullFIRInAppMessagingDisplayMessage*)inAppMessagedismissType:(FIRInAppMessagingDismissType)dismissType{// ...}@end
Firebase In-App Messagingby default allows you to trigger in-app messages with
Google Analytics for Firebase events, with no additional integration. You can
also manually trigger events programmatically with theFirebase In-App MessagingSDK’s
programmatic triggers.
In the In-App Messaging campaign composer, create a new campaign or select an
existing campaign, and in the Scheduling step of the composer workflow, note the
event ID of a newly-created or existing messaging event. Once noted, instrument
your app to trigger the event by its ID.
Swift
Note:This product is not available on macOS, Mac Catalyst, App Clip or watchOS targets.
…// somewhere in the app's codeInAppMessaging.inAppMessaging().triggerEvent("exampleTrigger");
Objective-C
Note:This product is not available on macOS, Mac Catalyst, App Clip or watchOS targets.
…// somewhere in the app's code[[FIRInAppMessaginginAppMessaging]triggerEvent:@"exampleTrigger"];
Use campaign custom metadata
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.
Swift
Note:This product is not available on macOS, Mac Catalyst, App Clip or watchOS targets.
classCardActionDelegate:NSObject,InAppMessagingDisplayDelegate{funcmessageClicked(_inAppMessage:InAppMessagingDisplayMessage){// Get data bundle from the inapp messageletappData=inAppMessage.appData// ...}}
By default,Firebase In-App Messagingrenders messages whenever a triggering condition is
satisfied, regardless of an app's current state. If you'd like to suppress
message displays for any reason, for example to avoid interrupting a
sequence of payment processing screens, use the SDK'smessageDisplaySuppressedproperty as illustrated here in Objective-C:
Setting the property toYESpreventsFirebase In-App Messagingfrom displaying messages,
whileNOreenables message display. The SDK resets the property toNOon app restart. Suppressed messages are ignored by the SDK. Their trigger
conditions must be met again while suppression is off, beforeFirebase In-App Messagingcan
display them.
Enable opt-out message delivery
By default,Firebase In-App Messagingautomatically delivers messages to all app users you target
in messaging campaigns. To deliver those messages, theFirebase In-App MessagingSDK usesFirebaseinstallation IDs to identify each user's app. This means
thatIn-App Messaginghas to send client data, linked to the
installation ID, to Firebase servers. If you'd like to give users
more control over the data they send, disable automatic data collection and give
them a chance to approve data sharing.
To do that, you have to disable automatic initialization forFirebase In-App Messaging, and
initialize the service manually for opt-in users:
Turn off automatic initialization with a new key in yourInfo.plistfile:
// Only needed if FirebaseInAppMessagingAutomaticDataCollectionEnabled is set to NO// in Info.plist[FIRInAppMessaginginAppMessaging].automaticDataCollectionEnabled=YES;
Once you setautomaticDataCollectionEnabledtoYES, the value persists
through app restarts, overriding the value in yourInfo.plist. If you'd like
to disable initialization again, for example if a user opts out of
collection later, set the property toNO.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-10-30 UTC."],[],[]]