توجه داشته باشید که افزودن Firebase به پروژه C++ شما شامل وظایفی هم در کنسول Firebase و هم در پروژه C++ باز شما می شود (به عنوان مثال، فایل های پیکربندی Firebase را از کنسول دانلود می کنید، سپس آنها را به پروژه C++ خود منتقل می کنید).
اضافه کردن طرحهای URL سفارشی (فقط برای iOS)
کتابخانه مشتری Firebase Dynamic Links C++ از طرحهای URL سفارشی در iOS برای پردازش پیوندها استفاده میکند. برای پشتیبانی از دریافت Dynamic Links ، باید طرحهای URL سفارشی را به برنامه خود اضافه کنید.
برای باز کردن پیکربندی پروژه خود، روی نام پروژه در نمای درختی سمت چپ دوبار کلیک کنید.
برنامه خود را از بخش TARGETS انتخاب کنید، سپس برگه Info را انتخاب کنید، سپس بخش URL Types را گسترش دهید.
روی دکمه + کلیک کنید، سپس یک طرح URL برای شناسه مشتری معکوس خود اضافه کنید. برای پیدا کردن این مقدار:
فایل پیکربندی GoogleService-Info.plist را باز کنید، سپس به دنبال کلید REVERSED_CLIENT_ID بگردید.
مقدار آن کلید را کپی کنید، سپس آن را در کادر URL Schemes در صفحه پیکربندی قرار دهید.
فیلدهای دیگر را خالی بگذارید.
روی دکمه + کلیک کنید، سپس یک طرح URL دوم را اضافه کنید. این یکی مانند شناسه بسته برنامه شما است.
برای مثال، اگر شناسه بسته شما com.example.ios است، آن مقدار را در کادر URL Schemes تایپ کنید.
میتوانید شناسه بسته برنامه خود را در برگه عمومی پیکربندی پروژه ( شناسه > شناسه بسته ) پیدا کنید.
دریافت Dynamic Link
ایجاد و مقداردهی اولیه برنامه
قبل از اینکه بتوانید Dynamic Links دریافتی را بررسی کنید، باید یک شی firebase::App ایجاد و مقداردهی اولیه کنید.
برای دریافت Dynamic Links ، کلاس Listener شما باید تابع مجازی OnDynamicLinkReceived را پیاده سازی کند. با نادیده گرفتن روش، می توانید یک پیوند عمیق دریافت کنید، اگر یکی دریافت شده باشد.
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());}};
تاریخ آخرین بهروزرسانی 2025-08-15 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-08-15 بهوقت ساعت هماهنگ جهانی."],[],[],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."]]