رفتار پیامهای پیامرسانی درونبرنامه Firebase را تغییر دهید
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Firebase In-App Messaging به شما امکان ایجاد، پیکربندی و هدفگیری تعاملات غنی با کاربر را میدهد و از قابلیتهای Google Analytics خارج از جعبه استفاده میکند تا رویدادهای پیامرسانی را با ویژگیها، فعالیتها و انتخابهای واقعی کاربر مرتبط کند. با برخی از ادغام Firebase In-App Messaging SDK، میتوانید رفتار پیامهای درونبرنامه را حتی بیشتر تنظیم کنید، در هنگام تعامل کاربران با پیامها پاسخ دهید، رویدادهای پیام خارج از چارچوب Analytics را راهاندازی کنید، و به کاربران اجازه دهید اشتراکگذاری دادههای شخصی خود را در ارتباط با تعاملات پیامرسانی کنترل کنند.
وقتی کاربران با پیامهای درونبرنامه تعامل دارند، پاسخ دهید
با کنشها میتوانید از پیامهای درونبرنامه خود برای هدایت کاربران به یک وبسایت یا صفحه خاصی در برنامه خود استفاده کنید.
کد شما میتواند به تعاملات اولیه (کلیکها و رد کردن)، به نمایشها (نماهای تأیید شده از پیامهای شما)، و نمایش خطاهای ثبتشده و تأیید شده توسط SDK پاسخ دهد. به عنوان مثال، زمانی که پیام شما به صورت کارتی ساخته می شود، ممکن است بخواهید ردیابی و پیگیری کنید که کاربر کدام یک از دو URL را روی کارت کلیک کرده است.
برای مدیریت تعاملات کارت، یک DisplayDelegate پیاده سازی کنید
میتوانید یک نماینده نمایش پیامرسان درونبرنامه را ثبت کنید که هر زمان که با پیام درونبرنامهای تعامل داشت، با او تماس گرفته میشود. برای انجام این کار، یک کلاس را در پروتکل InAppMessagingDisplayDelegate پیاده سازی کنید و آن را به عنوان ویژگی delegate در نمونه InAppMessaging تنظیم کنید.
مجدداً فرض کنید که می خواهید ردیابی کنید که کاربر روی کدام پیوند روی یک پیام به سبک کارت کلیک کرده است، کلاسی را تعریف کنید که متد messageClicked را در پروتکل DisplayDelegate پیاده سازی می کند و در نتیجه دسترسی شما را به پیوندی که کاربر کلیک کرده است را فراهم می کند.
سویفت
توجه: این محصول برای اهداف macOS، Mac Catalyst، App Clip یا watchOS موجود نیست.
برای مجموعه روشهای پاسخ به تماس قابل پیادهسازی و پارامترهای آنها، از جمله InAppMessagingAction، به مرجع نمایندگی نمایش Swift مراجعه کنید.
// In CardActionFiamDelegate.swiftclassCardActionFiamDelegate:NSObject,InAppMessagingDisplayDelegate{funcmessageClicked(_inAppMessage:InAppMessagingDisplayMessage){// ...}funcmessageDismissed(_inAppMessage:InAppMessagingDisplayMessage,dismissType:InAppMessagingDismissType){// ...}funcimpressionDetected(forinAppMessage:InAppMessagingDisplayMessage){// ...}funcdisplayError(forinAppMessage:InAppMessagingDisplayMessage,error:Error){// ...}}
// In AppDelegate.swift// Register the delegate with the InAppMessaging instanceletmyFiamDelegate=CardActionFiamDelegate()InAppMessaging.inAppMessaging().delegate=myFiamDelegate;
توجه: این محصول برای اهداف macOS، Mac Catalyst، App Clip یا watchOS موجود نیست.
برای مجموعه روشهای برگشت تماس قابل پیادهسازی و پارامترهای آنها، از جمله FIRINAppMessagingDisplayMessage، به مرجع نماینده نمایش Objective-C مراجعه کنید.
// In CardActionFiamDelegate.h@interfaceCardActionFiamDelegate : NSObject<FIRInAppMessagingDisplayDelegate>
@end// In CardActionFiamDelegate.m@implementationCardActionFiamDelegate-(void)displayErrorForMessage:(nonnullFIRInAppMessagingDisplayMessage*)inAppMessageerror:(nonnullNSError*)error{// ...}-(void)impressionDetectedForMessage:(nonnullFIRInAppMessagingDisplayMessage*)inAppMessage{// ...}-(void)messageClicked:(nonnullFIRInAppMessagingDisplayMessage*)inAppMessage{// ...}-(void)messageDismissed:(nonnullFIRInAppMessagingDisplayMessage*)inAppMessagedismissType:(FIRInAppMessagingDismissType)dismissType{// ...}@end
Firebase In-App Messaging به طور پیشفرض به شما امکان میدهد پیامهای درون برنامهای را با Google Analytics برای رویدادهای Firebase راهاندازی کنید، بدون اینکه یکپارچهسازی اضافی انجام شود. همچنین میتوانید بهصورت دستی رویدادها را بهصورت برنامهریزی با راهاندازهای برنامهای Firebase In-App Messaging SDK فعال کنید.
در آهنگساز کمپین پیامرسانی درونبرنامه، یک کمپین جدید ایجاد کنید یا یک کمپین موجود را انتخاب کنید، و در مرحله زمانبندی گردش کار آهنگساز، شناسه رویداد یک رویداد پیامرسانی جدید ایجاد شده یا موجود را یادداشت کنید. پس از یادداشت، برنامه خود را برای راه اندازی رویداد با شناسه آن ابزار کنید.
سویفت
توجه: این محصول برای اهداف macOS، Mac Catalyst، App Clip یا watchOS موجود نیست.
…// somewhere in the app's codeInAppMessaging.inAppMessaging().triggerEvent("exampleTrigger");
هدف-C
توجه: این محصول برای اهداف macOS، Mac Catalyst، App Clip یا watchOS موجود نیست.
…// somewhere in the app's code[[FIRInAppMessaginginAppMessaging]triggerEvent:@"exampleTrigger"];
از ابرداده های سفارشی کمپین استفاده کنید
در کمپین های خود، می توانید داده های سفارشی را در یک سری جفت کلید/مقدار مشخص کنید. هنگامی که کاربران با پیامها تعامل دارند، این دادهها برای مثال برای نمایش یک کد تبلیغاتی در دسترس شما هستند.
سویفت
توجه: این محصول برای اهداف macOS، Mac Catalyst، App Clip یا watchOS موجود نیست.
classCardActionDelegate:NSObject,InAppMessagingDisplayDelegate{funcmessageClicked(_inAppMessage:InAppMessagingDisplayMessage){// Get data bundle from the inapp messageletappData=inAppMessage.appData// ...}}
پیام های درون برنامه ای را به طور موقت غیرفعال کنید
بهطور پیشفرض، Firebase In-App Messaging پیامها را هر زمان که شرایط راهاندازی برآورده شود، بدون در نظر گرفتن وضعیت فعلی برنامه، ارائه میکند. اگر به هر دلیلی میخواهید نمایش پیامها را متوقف کنید، مثلاً برای جلوگیری از قطع شدن یک سری از صفحههای پردازش پرداخت، از ویژگی messageDisplaySuppressed SDK همانطور که در اینجا در Objective-C نشان داده شده است استفاده کنید:
تنظیم ویژگی روی YES مانع از نمایش پیامها Firebase In-App Messaging میشود، در حالی که NO نمایش پیام را دوباره فعال میکند. SDK با راه اندازی مجدد برنامه، ویژگی را به NO بازنشانی می کند. پیام های سرکوب شده توسط SDK نادیده گرفته می شوند. قبل از اینکه Firebase In-App Messaging بتواند آنها را نمایش دهد، باید شرایط راهاندازی آنها را دوباره در زمانی که سرکوب خاموش است برآورده کرد.
ارسال پیام انصراف را فعال کنید
بهطور پیشفرض، Firebase In-App Messaging بهطور خودکار پیامها را به همه کاربران برنامهای که در کمپینهای پیامرسانی هدف قرار میدهید، ارسال میکند. برای ارائه آن پیامها، Firebase In-App Messaging SDK از شناسههای نصب Firebase برای شناسایی برنامه هر کاربر استفاده میکند. این بدان معناست که In-App Messaging باید دادههای سرویس گیرنده را که به شناسه نصب مرتبط هستند، به سرورهای Firebase ارسال کند. اگر میخواهید به کاربران کنترل بیشتری بر دادههایی که ارسال میکنند بدهید، جمعآوری خودکار دادهها را غیرفعال کنید و به آنها فرصت دهید تا اشتراکگذاری دادهها را تأیید کنند.
برای انجام این کار، باید مقداردهی اولیه خودکار را برای Firebase In-App Messaging غیرفعال کنید و سرویس را به صورت دستی برای کاربرانی که انتخاب میکنند، راهاندازی کنید:
مقداردهی اولیه خودکار را با یک کلید جدید در فایل Info.plist خود خاموش کنید:
Firebase In-App Messaging برای کاربران منتخب به صورت دستی راه اندازی کنید:
// Only needed if FirebaseInAppMessagingAutomaticDataCollectionEnabled is set to NO// in Info.plist[FIRInAppMessaginginAppMessaging].automaticDataCollectionEnabled=YES;
هنگامی که automaticDataCollectionEnabled را روی YES تنظیم کردید، این مقدار از طریق راه اندازی مجدد برنامه باقی می ماند و مقدار Info.plist شما را نادیده می گیرد. اگر میخواهید مجدداً مقداردهی اولیه را غیرفعال کنید، برای مثال اگر کاربر بعداً از مجموعه انصراف داد، ویژگی را روی NO تنظیم کنید.
تاریخ آخرین بهروزرسانی 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\niOS+ Android Flutter \n\n\u003cbr /\u003e\n\nWith little to no coding effort, Firebase In-App Messaging allows you to create,\nconfigure and target rich user interactions, leveraging\nthe capabilities of Google Analytics out of the box\nto tie messaging events to actual user characteristics, activities, and choices.\nWith some additional Firebase In-App Messaging SDK integration, you can tailor\nthe behavior of in-app messages even further, responding when users interact\nwith messages, triggering message events outside the Analytics\nframework, and allowing users to control sharing of their personal data related\nto messaging interactions.\n\nRespond when users interact with in-app messages\n\nWith actions you can use your in-app messages to direct users to a\nwebsite or a specific screen in your app.\n\nYour code can respond to basic interactions (clicks and dismissals), to\nimpressions (verified views of your messages), and to display errors logged and\nconfirmed by the SDK. For example, when your message is composed as a Card\nmodal, you might want to track and follow-up on which of two URLs the user\nclicked on the Card.\n\nImplement a DisplayDelegate to handle Card interactions\n\nYou can register an in-app messaging display delegate that will be called\nwhenever there is any interaction with an in-app message. To do this, implement\na class per the `InAppMessagingDisplayDelegate` protocol and set it as the\ndelegate property on the `InAppMessaging` instance.\n\nAssuming again that you want to track which link a user clicked on a Card-style\nmessage, define a class that implements the `messageClicked` method per the\n`DisplayDelegate` protocol, thereby providing you access to the\nlink clicked by the user. \n\nSwift\n\n\n**Note:** This product is not available on macOS, Mac Catalyst, App Clip or watchOS targets.\n\nRefer to the Swift [display delegate reference](/docs/reference/swift/firebaseinappmessaging/api/reference/Protocols/InAppMessagingDisplayDelegate) for the set of callback methods that can be implemented and their parameters, including\nInAppMessagingAction. \n\n\n // In CardActionFiamDelegate.swift\n class CardActionFiamDelegate : NSObject, InAppMessagingDisplayDelegate {\n\n func messageClicked(_ inAppMessage: InAppMessagingDisplayMessage) {\n // ...\n }\n\n func messageDismissed(_ inAppMessage: InAppMessagingDisplayMessage,\n dismissType: InAppMessagingDismissType) {\n // ...\n }\n\n func impressionDetected(for inAppMessage: InAppMessagingDisplayMessage) {\n // ...\n }\n\n func displayError(for inAppMessage: InAppMessagingDisplayMessage, error: Error) {\n // ...\n }\n\n } \n https://github.com/firebase/snippets-ios/blob/cdce007fedb3bb90dd3a70ce03066178236e1deb/inappmessaging/FIAMReference/FIAMReferenceSwift/CardActionFiamDelegate.swift#L20-L39\n\n\n // In AppDelegate.swift\n // Register the delegate with the InAppMessaging instance\n let myFiamDelegate = CardActionFiamDelegate()\n InAppMessaging.inAppMessaging().delegate = myFiamDelegate; \n https://github.com/firebase/snippets-ios/blob/cdce007fedb3bb90dd3a70ce03066178236e1deb/inappmessaging/FIAMReference/FIAMReferenceSwift/AppDelegate.swift#L30-L32\n\nObjective-C\n\n\n**Note:** This product is not available on macOS, Mac Catalyst, App Clip or watchOS targets.\n\nRefer to the Objective-C [display delegate reference](/docs/reference/ios/firebaseinappmessaging/api/reference/Protocols/FIRInAppMessagingDisplayDelegate) for the set of callback methods that can be implemented and their parameters, including\nFIRInAppMessagingDisplayMessage. \n\n\n // In CardActionFiamDelegate.h\n @interface CardActionFiamDelegate : NSObject \u003cFIRInAppMessagingDisplayDelegate\u003e\n @end\n\n // In CardActionFiamDelegate.m\n @implementation CardActionFiamDelegate\n\n - (void)displayErrorForMessage:(nonnull FIRInAppMessagingDisplayMessage *)inAppMessage\n error:(nonnull NSError *)error {\n // ...\n }\n\n - (void)impressionDetectedForMessage:(nonnull FIRInAppMessagingDisplayMessage *)inAppMessage {\n // ...\n }\n\n - (void)messageClicked:(nonnull FIRInAppMessagingDisplayMessage *)inAppMessage {\n // ...\n }\n\n - (void)messageDismissed:(nonnull FIRInAppMessagingDisplayMessage *)inAppMessage\n dismissType:(FIRInAppMessagingDismissType)dismissType {\n // ...\n }\n\n @end \n https://github.com/firebase/snippets-ios/blob/cdce007fedb3bb90dd3a70ce03066178236e1deb/inappmessaging/FIAMReference/FIAMReference/CardActionFiamDelegate.m#L20-L40\n\n\n // In AppDelegate.m\n CardActionFiamDelegate *myFiamDelegate = [CardActionFiamDelegate new];\n [FIRInAppMessaging inAppMessaging].delegate = myFiamDelegate; \n https://github.com/firebase/snippets-ios/blob/cdce007fedb3bb90dd3a70ce03066178236e1deb/inappmessaging/FIAMReference/FIAMReference/AppDelegate.m#L35-L36\n\nTrigger in-app messages programmatically\n\nFirebase In-App Messaging by default allows you to trigger in-app messages with\nGoogle Analytics for Firebase events, with no additional integration. You can\nalso manually trigger events programmatically with the Firebase In-App Messaging SDK's\nprogrammatic triggers.\n\nIn the In-App Messaging campaign composer, create a new campaign or select an\nexisting campaign, and in the Scheduling step of the composer workflow, note the\nevent ID of a newly-created or existing messaging event. Once noted, instrument\nyour app to trigger the event by its ID. \n\nSwift\n\n\n**Note:** This product is not available on macOS, Mac Catalyst, App Clip or watchOS targets. \n\n ...\n // somewhere in the app's code\n InAppMessaging.inAppMessaging().triggerEvent(\"exampleTrigger\");\n\nObjective-C\n\n\n**Note:** This product is not available on macOS, Mac Catalyst, App Clip or watchOS targets. \n\n ...\n // somewhere in the app's code\n [[FIRInAppMessaging inAppMessaging] triggerEvent:@\"exampleTrigger\"];\n\nUse campaign custom metadata\n\nIn your campaigns, you can specify custom data in a series of key/value pairs.\nWhen users interact with messages, this data is available for you to, for example,\ndisplay a promo code. \n\nSwift\n\n\n**Note:** This product is not available on macOS, Mac Catalyst, App Clip or watchOS targets. \n\n class CardActionDelegate : NSObject, InAppMessagingDisplayDelegate {\n\n func messageClicked(_ inAppMessage: InAppMessagingDisplayMessage) {\n \t// Get data bundle from the inapp message\n \tlet appData = inAppMessage.appData\n \t// ...\n }\n } \n https://github.com/firebase/snippets-ios/blob/cdce007fedb3bb90dd3a70ce03066178236e1deb/inappmessaging/FIAMReference/FIAMReferenceSwift/CardActionFiamDelegate.swift#L44-L51\n\nObjective-C\n\n\n**Note:** This product is not available on macOS, Mac Catalyst, App Clip or watchOS targets. \n\n @implementation ExampleCardActionDelegate\n\n - (void)messageClicked:(nonnull FIRInAppMessagingDisplayMessage *)inAppMessage {\n NSDictionary *appData = inAppMessage.appData;\n NSLog(@\"Message data: %@\", appData);\n \t// ...\n }\n\n @end \n https://github.com/firebase/snippets-ios/blob/cdce007fedb3bb90dd3a70ce03066178236e1deb/inappmessaging/FIAMReference/FIAMReference/CardActionFiamDelegate.m#L48-L56\n\nTemporarily disable in-app messages\n\nBy default, Firebase In-App Messaging renders messages whenever a triggering condition is\nsatisfied, regardless of an app's current state. If you'd like to suppress\nmessage displays for any reason, for example to avoid interrupting a\nsequence of payment processing screens, use the SDK's\n`messageDisplaySuppressed` property as illustrated here in Objective-C: \n\n [FIRInAppMessaging inAppMessaging].messageDisplaySuppressed = YES; \n https://github.com/firebase/snippets-ios/blob/cdce007fedb3bb90dd3a70ce03066178236e1deb/inappmessaging/FIAMReference/FIAMReference/ViewController.m#L31-L31\n\nSetting the property to `YES` prevents Firebase In-App Messaging from displaying messages,\nwhile `NO` reenables message display. The SDK resets the property to `NO`\non app restart. Suppressed messages are ignored by the SDK. Their trigger\nconditions must be met again while suppression is off, before Firebase In-App Messaging can\ndisplay them.\n\nEnable opt-out message delivery\n\nBy default, Firebase In-App Messaging automatically delivers messages to all app users you target\nin messaging campaigns. To deliver those messages, the Firebase In-App Messaging SDK uses\nFirebase installation IDs to identify each user's app. This means\nthat In-App Messaging has to send client data, linked to the\ninstallation ID, to Firebase servers. If you'd like to give users\nmore control over the data they send, disable automatic data collection and give\nthem a chance to approve data sharing.\n\nTo do that, you have to disable automatic initialization for Firebase In-App Messaging, and\ninitialize the service manually for opt-in users:\n\n1. Turn off automatic initialization with a new key in your `Info.plist` file:\n\n - Key: `FirebaseInAppMessagingAutomaticDataCollectionEnabled`\n - Value: `NO`\n2. Initialize Firebase In-App Messaging for selected users manually:\n\n // Only needed if FirebaseInAppMessagingAutomaticDataCollectionEnabled is set to NO\n // in Info.plist\n [FIRInAppMessaging inAppMessaging].automaticDataCollectionEnabled = YES; \n https://github.com/firebase/snippets-ios/blob/cdce007fedb3bb90dd3a70ce03066178236e1deb/inappmessaging/FIAMReference/FIAMReference/ViewController.m#L37-L39\n\n Once you set `automaticDataCollectionEnabled` to `YES`, the value persists\n through app restarts, overriding the value in your `Info.plist`. If you'd like\n to disable initialization again, for example if a user opts out of\n collection later, set the property to `NO`."]]