Get started with Firebase In-App Messaging

This quickstart shows you how to set up Firebase In-App Messaging and send your first message.

Before you begin

Install and initialize the Firebase SDKs for Flutter if you haven't already done so.

Add the Firebase In-App Messaging SDK to your project

  1. From the root directory of your Flutter project, run the following command to install the Firebase In-App Messaging plugin:

    flutter pub add firebase_in_app_messaging
    
  2. Rebuild your project:

    flutter run
    
  3. Import the Firebase In-App Messaging plugin:

    import 'package:firebase_in_app_messaging/firebase_in_app_messaging.dart';
    

Send a test message

Get your app's installation ID

To conserve power, Firebase In-App Messaging only retrieves messages from the server once per day. That can make testing difficult, so the Firebase console allows you to specify a test device that displays messages on demand.

That testing device is determined by a FID. Find your testing app's FID by checking the console output when you run your app.

On Android, the message looks like the following:

I/FIAM.Headless: Starting InAppMessaging runtime with Installation ID YOUR_INSTALLATION_ID

On iOS, run the app with the runtime command argument -FIRDebugEnabled:

  1. With your Xcode project open, select Product > Scheme > Edit scheme... from the top menu bar.
  2. Open the Arguments tab of the dialog that pops up.
  3. Click + Add items under Arguments Passed On Launch.
  4. Enter "-FIRDebugEnabled" in the newly-created field.
  5. Click Close, then run your app.

Once your app starts running, look for the following line in the Xcode console's logs:

[Firebase/InAppMessaging][I-IAM180017] Starting InAppMessaging runtime with Firebase Installation ID YOUR_INSTALLATION_ID

Send a message to your testing device

Once you've launched your app on the testing device and you have its Firebase installation ID (FID), you can try out your Firebase In-App Messaging setup by sending a test message:

  1. In the Firebase console, open Messaging.
  2. If this is your first campaign, click Create your first campaign.
    1. Select Firebase In-App messages and click Create.
  3. Otherwise, on the Campaigns tab, click New campaign.
    1. Select In-App Messaging.
  4. Enter a Title for your first message.
  5. Click Test on your Device
  6. Enter your app's Firebase installation ID in the Add an installation ID field.
  7. Click Test to send the message.

Firebase In-App Messaging sends your test message as soon as you click Test. To see the message, you need to close, then reopen the app on your testing device.

To confirm whether your device is a test device, look for one of the following log messages.

Android

I/FIAM.Headless: Setting this device as a test device

iOS

[Firebase/InAppMessaging][I-IAM180017] Seeing test message in fetch response. Turn the current instance into a testing instance.