classListener:publicfirebase::dynamic_links::Listener{public:// Called on the client when a dynamic link arrives.voidOnDynamicLinkReceived(constfirebase::dynamic_links::DynamicLink*dynamic_link)override{printf("Received link: %s",dynamic_link->url.c_str());}};
[null,null,["最后更新时间 (UTC):2025-08-16。"],[],[],null,["\u003cbr /\u003e\n\n| **Deprecated:** Firebase Dynamic Links is *deprecated* and should not be adopted in projects that don't already use it. The service will shut down on August 25, 2025. See the [Dynamic Links Deprecation FAQ](/support/dynamic-links-faq) for more information.\n\nTo receive the Firebase Dynamic Links that [you created](/docs/dynamic-links/create-links),\nyou must include the Dynamic Links SDK in your app and create a\n[`firebase::dynamic_links::Listener`](/docs/reference/cpp/class/firebase/dynamic-links/listener)\nobject that implements the\n[`OnDynamicLinkReceived`](/docs/reference/cpp/class/firebase/dynamic-links/listener#ondynamiclinkreceived)\nvirtual function.\n\nThe C++ SDK works for both Android and iOS, with some additional setup required\nfor each platform.\n\nBefore you begin\n\nBefore you can use\n[Firebase Dynamic Links](/docs/reference/unity/namespace/firebase/dynamic-links),\nyou need to:\n\n- Register your C++ project and configure it to use Firebase.\n\n If your C++ project already uses Firebase, then it's already registered and\n configured for Firebase.\n- Add the [Firebase C++ SDK](/download/cpp) to your C++ project.\n\n| **Find detailed instructions for these initial\n| setup tasks in\n| [Add Firebase to your C++\n| project](/docs/cpp/setup#note-select-platform).**\n\nNote that adding Firebase to your C++ project involves tasks both in the\n[Firebase console](//console.firebase.google.com/) and in your open C++ project (for example, you download\nFirebase config files from the console, then move them into your C++ project).\n\nAdd custom URL schemes (for iOS only)\n\nThe Firebase Dynamic Links C++ client library uses custom URL schemes on iOS to\nprocess links. You must add custom URL schemes to your app to support receiving\nDynamic Links.\n\n1. To open your project configuration, double-click the project name in the left\n tree view.\n\n2. Select your app from the **TARGETS** section, then select the **Info** tab,\n then expand the **URL Types** section.\n\n3. Click the **+** button, then add a URL scheme for your reversed client ID. To\n find this value:\n\n 1. Open the GoogleService-Info.plist configuration file, then look for the\n `REVERSED_CLIENT_ID` key.\n\n 2. Copy the value of that key, then paste it into the **URL Schemes** box on\n the configuration page.\n\n 3. Leave the other fields blank.\n\n4. Click the **+** button, then add a second URL scheme. This one is the same as\n your app's bundle ID.\n\n For example, if your bundle ID is `com.example.ios`, type that value into the\n **URL Schemes** box.\n\n You can find your app's bundle ID in the **General** tab of the project\n configuration (**Identity \\\u003e Bundle Identifier**).\n\nReceiving a Dynamic Link\n\nCreate and initialize App\n\nBefore you can check for received Dynamic Links, you'll need to create and initialize\na [`firebase::App`](/docs/reference/cpp/class/firebase/app) object.\n| You only need to initialize firebase::App once, no matter how many Firebase C++ features you use.\n\nInclude the header file for `firebase::App`: \n\n```c++\n#include \"firebase/app.h\"\n```\n\nThe next part varies depending on your platform: \n\nAndroid\n\n\nCreate the `firebase::App`, passing the JNI environment and a `jobject`\nreference to the Java Activity as arguments: \n\n```c++\napp = ::firebase::App::Create(::firebase::AppOptions(\"APPLICATION NAME\"), jni_env, activity);\n```\n\niOS\n\n\nCreate the `firebase::App`: \n\n```c++\napp = ::firebase::App::Create(::firebase::AppOptions(\"APPLICATION NAME\"));\n```\n\nImplement Listener to check for Dynamic Links\n\nTo check for a received Dynamic Link, implement and use the\n[`firebase::dynamic_links::Listener`](/docs/reference/cpp/class/firebase/dynamic-links/listener)\nclass.\n\nInclude the header file for receiving Dynamic Links: \n\n```c++\n#include \"firebase/dynamic_links.h\"\n```\n\n\u003cbr /\u003e\n\n[Initialize](/docs/reference/cpp/namespace/firebase/dynamic-links#initialize) the Dynamic Links library: \n\n```c++\n::firebase::dynamic_links::Initialize(app, null);\n```\n\n\u003cbr /\u003e\n\nCreate an object that implements\n[`firebase::dynamic_links::Listener`](/docs/reference/cpp/class/firebase/dynamic-links/listener),\nand supply it to the Dynamic Links library with\n[`SetListener()`](/docs/reference/cpp/namespace/firebase/dynamic-links#setlistener),\nor pass it as the second argument to\n[Initialize](/docs/reference/cpp/namespace/firebase/dynamic-links#initialize).\n\nTo receive Dynamic Links, your Listener class must implement the\n[`OnDynamicLinkReceived`](/docs/reference/cpp/class/firebase/dynamic-links/listener#ondynamiclinkreceived)\nvirtual function. By overriding the method, you can receive a deep link, if\none was received. \n\n```c++\nclass Listener : public firebase::dynamic_links::Listener {\n public:\n // Called on the client when a dynamic link arrives.\n void OnDynamicLinkReceived(\n const firebase::dynamic_links::DynamicLink* dynamic_link) override {\n printf(\"Received link: %s\", dynamic_link-\u003eurl.c_str());\n }\n};\n```\n| **Note:** On Android you must also call [`Fetch()`](/docs/reference/cpp/namespace/firebase/dynamic-links#fetch) when the application gains focus in order for the listener to be triggered."]]