Firebase In-App Messaging SDK را به پروژه خود اضافه کنید
در فایل Gradle ماژول (سطح برنامه) خود (معمولا <project>/<app-module>/build.gradle.kts یا <project>/<app-module>/build.gradle )، وابستگی را برای کتابخانه In-App Messaging برای Android اضافه کنید. توصیه میکنیم از Firebase Android BoM برای کنترل نسخهسازی کتابخانه استفاده کنید.
dependencies{// Import the BoM for the Firebase platformimplementation(platform("com.google.firebase:firebase-bom:34.2.0"))// Add the dependencies for the In-App Messaging and Analytics libraries// When using the BoM, you don't specify versions in Firebase library dependenciesimplementation("com.google.firebase:firebase-inappmessaging-display")implementation("com.google.firebase:firebase-analytics")}
با استفاده از Firebase Android BoM ، برنامه شما همیشه از نسخههای سازگار کتابخانههای Firebase Android استفاده میکند.
(جایگزین) وابستگی های کتابخانه Firebase را بدون استفاده از BoM اضافه کنید
اگر تصمیم گرفتید از Firebase BoM استفاده نکنید، باید هر نسخه کتابخانه Firebase را در خط وابستگی آن مشخص کنید.
توجه داشته باشید که اگر از چندین کتابخانه Firebase در برنامه خود استفاده می کنید، ما قویاً توصیه می کنیم از BoM برای مدیریت نسخه های کتابخانه استفاده کنید، که تضمین می کند همه نسخه ها سازگار هستند.
dependencies{// Add the dependencies for the In-App Messaging and Analytics libraries// When NOT using the BoM, you must specify versions in Firebase library dependenciesimplementation("com.google.firebase:firebase-inappmessaging-display:22.0.0")implementation("com.google.firebase:firebase-analytics:23.0.0")}
یک پیام آزمایشی ارسال کنید
شناسه نصب برنامه خود را دریافت کنید
برای صرفه جویی در مصرف برق، Firebase In-App Messaging فقط یک بار در روز پیام ها را از سرور بازیابی می کند. این می تواند آزمایش را دشوار کند، بنابراین کنسول Firebase به شما امکان می دهد یک دستگاه آزمایشی را مشخص کنید که پیام ها را در صورت درخواست نمایش می دهد.
آن دستگاه تست توسط یک ID FirebaseInstallations یا FID تعیین می شود. با بررسی Logcat در Android Studio برای گزارش سطح «اطلاعات» زیر، FID برنامه آزمایشی خود را پیدا کنید:
I/FIAM.Headless: Starting InAppMessaging runtime with Installation ID YOUR_INSTALLATION_ID
به دستگاه تست خود پیام ارسال کنید
هنگامی که برنامه خود را روی دستگاه آزمایشی راه اندازی کردید و شناسه نصب Firebase (FID) آن را دریافت کردید، می توانید با ارسال یک پیام آزمایشی، تنظیمات Firebase In-App Messaging را امتحان کنید:
اگر این اولین کمپین شما است، روی ایجاد اولین کمپین خود کلیک کنید.
Firebase In-App messages را انتخاب کنید و روی ایجاد کلیک کنید.
در غیر این صورت، در تب کمپین ها ، روی کمپین جدید کلیک کنید.
پیام درون برنامه را انتخاب کنید.
عنوانی را برای اولین پیام خود وارد کنید.
روی Test on Device کلیک کنید
شناسه نصب Firebase برنامه خود را در قسمت Add an install ID وارد کنید.
برای ارسال پیام روی Test کلیک کنید.
Firebase In-App Messaging به محض کلیک روی Test ، پیام آزمایشی شما را ارسال میکند. برای مشاهده پیام، باید آن را ببندید، سپس برنامه را در دستگاه آزمایشی خود دوباره باز کنید.
برای تأیید اینکه آیا دستگاه شما یک دستگاه آزمایشی است، به دنبال پیام گزارش زیر باشید:
I/FIAM.Headless: Setting this device as a test device
تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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-04 بهوقت ساعت هماهنگ جهانی."],[],[],null,["\u003cbr /\u003e\n\nThis quickstart shows you how to set up Firebase In-App Messaging and send your first message. \niOS+ Android Flutter \n\n\u003cbr /\u003e\n\nBefore you begin\n\n\nBefore starting, make sure to [add Firebase to your Apple project](/docs/ios/setup).\n\nAdd the Firebase In-App Messaging SDK to your project\n\n\nUse Swift Package Manager to install and manage Firebase dependencies.\n| Visit [our installation guide](/docs/ios/installation-methods) to learn about the different ways you can add Firebase SDKs to your Apple project, including importing frameworks directly and using CocoaPods.\n\n1. In Xcode, with your app project open, navigate to **File \\\u003e Add Packages**.\n2. When prompted, add the Firebase Apple platforms SDK repository: \n\n```text\n https://github.com/firebase/firebase-ios-sdk.git\n```\n| **Note:** New projects should use the default (latest) SDK version, but you can choose an older version if needed.\n3. Choose the In-App Messaging library.\n4. Add the `-ObjC` flag to the *Other Linker Flags* section of your target's build settings.\n5. To use In-App Messaging, you must [enable Google Analytics](//support.google.com/firebase/answer/9289399#linkga) in your Firebase project and add the Firebase SDK for Google Analytics to your app. You can select either the library without IDFA collection or with IDFA collection. See our FAQ on the [latest organization of modules in the Google Analytics for Firebase SDK](/support/faq#analytics-odm2-sdk-refactor-ios).\n6. When finished, Xcode will automatically begin resolving and downloading your dependencies in the background.\n\nNow, initialize the SDK in your app:\n\n1. Import the Firebase module in your `App` struct or `UIApplicationDelegate`, if you haven't yet: \n\n Swift \n\n ```swift\n import Firebase\n ```\n\n Objective-C \n\n ```objective-c\n @import Firebase;\n ```\n2. Also configure a [`FirebaseApp`](/docs/reference/ios/firebasecore/api/reference/Classes/FIRApp) shared instance, typically in your `App`'s initializer or your app delegate's `application(_:didFinishLaunchingWithOptions:)` method, if you haven't yet: \n\n Swift \n\n ```swift\n FirebaseApp.configure()\n ```\n\n Objective-C \n\n ```objective-c\n [FIRApp configure];\n ```\n3. Compile and run your app.\n\n| **Note:** Firebase In-App Messaging requires Firebase version 5.6.0 or higher. If you're having trouble compiling your app, try running `pod update` in your app's project directory. Keep in mind, though, that the command updates all of your app's dependencies, not just Firebase ones.\n\n\u003cbr /\u003e\n\nSend a test message\n\nGet your app's installation ID\n\nTo conserve power, Firebase In-App Messaging only retrieves messages from the\nserver once per day. That can make testing difficult, so the\nFirebase console allows you to specify a test device that displays messages\non demand.\n\n\nThat testing device is determined by a Firebase installation ID provided by the\nFirebase installations service. To find your testing app's installation ID, run the app with the\nruntime command argument `-FIRDebugEnabled`:\n\n1. With your Xcode project open, select **Product \\\u003e Scheme \\\u003e Edit scheme...** from the top menu bar.\n2. Open the **Arguments** tab of the dialog that pops up.\n3. Click **+ Add items** under **Arguments Passed On Launch**.\n4. Enter \"-FIRDebugEnabled\" in the newly-created field.\n5. Click **Close**, then run your app.\n\nOnce your app starts running, look for the following line in the Xcode console's logs: \n\n```scdoc\n[Firebase/InAppMessaging][I-IAM180017] Starting InAppMessaging runtime with Firebase Installation ID YOUR_INSTALLATION_ID\n```\n\n\u003cbr /\u003e\n\nSend a message to your testing device\n\nOnce you've launched your app on the testing device and you have its\nFirebase installation ID (FID), you can try out your Firebase In-App Messaging\nsetup by sending a test message:\n\n1. In the Firebase console, open the [Messaging page](https://console.firebase.google.com/project/_/messaging/).\n2. If this is your first campaign, click **Create your first campaign** .\n 1. Select **Firebase In-App messages** and click **Create**.\n3. Otherwise, on the **Campaigns** tab, click **New campaign** .\n 1. Select **In-App Messaging**.\n4. Enter a **Title** for your first message.\n5. Click **Test on Device**\n6. Enter your app's Firebase installation ID in the **Add an installation ID** field.\n7. Click **Test** to send the message.\n\nFirebase In-App Messaging sends your test message as soon as you click **Test**. To see the\nmessage, you need to close, then reopen the app on your testing device.\n\nTo confirm whether your device is a test device, look for the following\nlog message: \n\n```\n[Firebase/InAppMessaging][I-IAM180017] Seeing test message in fetch response. Turn the current instance into a testing instance.\n```"]]