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::dynamic_links::Listener object that implements the OnDynamicLinkReceivedvirtual function.
The C++ SDK works for both Android and iOS, with some additional setup required for each platform.
Before you begin
Before you can use Firebase Dynamic Links, you need to:
- Register your C++ project and configure it to use Firebase.If your C++ project already uses Firebase, then it's already registered and configured for Firebase.
- In your project-level
build.gradlefile, make sure to include Google's Maven repository in both yourbuildscriptandallprojectssections.
Note that adding Firebase to your C++ project involves tasks both in the Firebase console and in your open C++ project (for example, you download Firebase config files from the console, then move them into your C++ project).
Add custom URL schemes (for iOS only)
The Firebase Dynamic Links 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.
- 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, then expand the URL Types section.
- Click the + button, then add a URL scheme for your reversed client ID. To find this value:
- Open the
GoogleService-Info.plistconfiguration file, then look for theREVERSED_CLIENT_IDkey. - Copy the value of that key, then paste it into the URL Schemes box on the configuration page.
- Leave the other fields blank.
- Click the + button, then add a second URL scheme. This one is the same as your app's bundle ID.For example, if your bundle ID is
com.example.ios, 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).
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:
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:Implement Listener to check for Dynamic Links
To check for a received Dynamic Link, implement and use the
firebase::dynamic_links::Listener class.
Include the header file for receiving Dynamic Links:
Initialize the Dynamic Links library:
Create an object that implements
firebase::dynamic_links::Listener, and supply it to the Dynamic Links library with SetListener(), or pass it as the second argument to Initialize.
To receive Dynamic Links, your Listener class must implement the
OnDynamicLinkReceived virtual function. By overriding the method, you can receive a deep link, if one was received.
Comments
Post a Comment