يُرجى العِلم أنّ إضافة Firebase إلى مشروع C++ يتضمّن مهامًا في كل من
وحدة تحكّم Firebase ومشروع C++ المفتوح (على سبيل المثال، يمكنك تنزيل
ملفات إعداد Firebase من وحدة التحكّم، ثم نقلها إلى مشروع C++).
إضافة مخططات عناوين URL مخصّصة (لأجهزة iOS فقط)
تستخدم مكتبة عميل Firebase Dynamic Links C++ مخطّطات عناوين URL مخصّصة على أجهزة iOS لمعالجة الروابط. يجب إضافة مخطّطات عناوين URL مخصّصة إلى تطبيقك لتتمكّن من تلقّي Dynamic Links.
لفتح إعدادات مشروعك، انقر مرّتين على اسم المشروع في العرض الشجري على يمين الصفحة.
اختَر تطبيقك من قسم الاستهدافات، ثم انقر على علامة التبويب المعلومات، ثم وسِّع قسم أنواع عناوين URL.
انقر على الزر +، ثم أضِف مخطط عنوان URL لمعرّف العميل المعكوس. للعثور على هذه القيمة، اتّبِع الخطوات التالية:
افتح ملف الإعداد GoogleService-Info.plist، ثم ابحث عن المفتاح REVERSED_CLIENT_ID.
انسخ قيمة هذا المفتاح، ثم الصِقها في مربّع مخططات عناوين URL في صفحة الإعدادات.
اترك الحقول الأخرى فارغة.
انقر على الزر +، ثم أضِف نظام عنوان URL ثانيًا. هذا المعرّف هو نفسه معرّف حزمة تطبيقك.
على سبيل المثال، إذا كان معرّف الحزمة هو com.example.ios، أدخِل هذه القيمة في مربّع مخططات عناوين URL.
يمكنك العثور على معرّف حزمة تطبيقك في علامة التبويب عام ضمن إعدادات المشروع (الهوية > معرّف الحزمة).
تلقّي Dynamic Link
إنشاء التطبيق وتهيئته
قبل أن تتمكّن من التحقّق من Dynamic Links المستلَمة، عليك إنشاء عنصر firebase::App وتهيئته.
ضمِّن ملف العناوين لـ firebase::App:
#include"firebase/app.h"
يختلف الجزء التالي حسب المنصة التي تستخدمها:
Android
أنشئ firebase::App، مع تمرير بيئة JNI ومرجع jobject
إلى نشاط Java كمعلَمات:
لتلقّي Dynamic Links، يجب أن تنفّذ فئة المستمع الدالة الظاهرية
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-09-03 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-09-03 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["\u003cbr /\u003e\n\n| **Note:** Firebase Dynamic Links is *deprecated* and should not be used in new projects. The service will be shutting down soon. Follow the [migration guide](/support/dynamic-links-faq#how_should_i_migrate_from_the_service) and 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."]]