Google is committed to advancing racial equity for Black communities. See how.

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

Before you begin, you need a few things set up in your environment:

  • An app with Firebase enabled: If you haven't already, add Firebase to your iOS project.
  • Xcode 11.0 or higher: Firebase In-App Messaging needs a relatively-recent version of Xcode to run. You can find the latest Xcode version at Apple's Xcode site.
  • CocoaPods 1.4.0 or higher: Firebase In-App Messaging uses CocoaPods to manage dependencies on iOS. You can install it from the CocoaPods site.

Add the Firebase In-App Messaging SDK to your project

To get started, add the Firebase In-App Messaging SDK framework files to your project by adding the Firebase In-App Messaging CocoaPods:

  1. Open a new terminal window, and navigate to your Xcode project's directory.
  2. Open your Podfile, and add the highlighted lines:
    # Uncomment the next line to define a global platform for your project
    # platform :ios, '9.0'
    target 'YourProject' do
    # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
    # Pods for YourProject
    pod 'Firebase'
    pod 'Firebase/InAppMessaging'
    pod 'Firebase/Analytics'
  3. From your terminal, install the pod's dependencies:
    pod install
  4. Open your app's project in Xcode:
    open YOUR-PROJECT.xcworkspace
  5. Import the Firebase module in your UIApplicationDelegate, if you haven't yet:
    import Firebase
    @import Firebase;
  6. Also configure a FirebaseApp shared instance, typically in your app's application:didFinishLaunchingWithOptions: method, if you haven't yet:
    // Use Firebase library to configure APIs
    // Use Firebase library to configure APIs
    [FIRApp configure];
  7. Compile and run your app.

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 Firebase installation ID provided by the Firebase installations service. To find your testing app's installation ID, 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_APP_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 Firebase In-App Messaging setup by sending a test message:

  1. In the Firebase console, open In-App Messaging.
  2. Once there, click New Campaign.
  3. Enter a Title for your first message.
  4. Click Test on your Device
  5. Enter your app's Firebase installation ID in the Add an installation ID field.
  6. Click Test to send the message.

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

To confirm whether your device is a test device, look for the following log message:

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