Receive Dynamic Links with C++

To receive the Firebase Dynamic Links that you created, you must include the Dynamic Links SDK in your app and create a firebase::invites::Listener object that implements the OnInviteReceived virtual function.

The C++ SDK works for both Android and iOS, with some additional setup required for each platform.

Before you begin


  1. If you haven't yet connected your app to your Firebase project, do so from the Firebase console.
  2. Add Firebase to your Android project.
  3. Add the dependency for Firebase Invites to your app-level build.gradle file:
    dependencies {
         compile ''
  4. Link the libapp.a and libinvites.a static library, from the C++ SDK.


  1. If you haven't yet connected your app to your Firebase project, do so from the Firebase console.
  2. Add Firebase to your iOS project.
  3. The Firebase Invites C++ client library uses custom URL schemes on iOS to process links. You must add custom URL schemes to your app to support receiving Dynamic Links:
    1. To open your project configuration, double-click the project name in the left tree view. Select your app from the TARGETS section, then select the Info tab, and expand the URL Types section.
    2. Click the + button, and add a URL scheme for your reversed client ID. To find this value, open the GoogleService-Info.plist configuration file, and look for the REVERSED_CLIENT_ID key. Copy the value of that key, and paste it into the URL Schemes box on the configuration page. Leave the other fields blank.
    3. Click the + button, and add a second URL scheme. This one is the same as your app's bundle ID. For example, if your bundle ID is, type that value into the URL Schemes box. You can find your app's bundle ID in the General tab of the project configuration (Identity > Bundle Identifier).
  4. Include the following Pod in your Podfile:
    pod 'Firebase/Invites'
  5. Run pod install
  6. Add firebase.framework and firebase_invites.framework, from the C++ SDK, to your Xcode project.

Receiving a Dynamic Link

Create and initialize App

Before you can check for received Dynamic Links, you'll need to create and initialize a firebase::App object.

Include the header file for firebase::App:

#include "firebase/app.h"

The next part varies depending on your platform:


Create the firebase::App, passing the JNI environment and a jobject reference to the Java Activity as arguments:

app = ::firebase::App::Create(::firebase::AppOptions("APPLICATION NAME"), jni_env, activity);


Create the firebase::App:

app = ::firebase::App::Create(::firebase::AppOptions("APPLICATION NAME"));

Implement Listener to check for Dynamic Links

The Firebase Invites C++ library is also used for receiving Dynamic Links. To check for a received Dynamic Link, implement and use the firebase::invites::Listener class.

Include the header file for receiving Invites:

#include "firebase/invites.h"

Initialize the Invites library:


Create an object that implements firebase::invites::Listener, and supply it to the Invites library with SetListener().

To receive invitations, your Listener class must implement the OnInviteReceived virtual function. By overriding the method, you can receive a deep link, if one was received.

void OnInviteReceived(const char* invitation_id, const char* deep_link,
                      bool is_strong_match) override {
  if (deep_link != nullptr) {
    // The app received a Dynamic Link. This may have come from an invitation
    // (if invite.invitation_id is set), or it might have been sent using
    // Firebase Dynamic Links.
    // In any event, the app can now act on this link as you see fit.
  if (invitation_id != nullptr) {
    // We received an invitation ID. See the Firebase Invites documentation
    // for more information.

Send feedback about...

Need help? Visit our support page.