تنظیم حالت رضایت برای برنامه ها، تنظیم حالت رضایت برای برنامه ها
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این صفحه برای توسعه دهندگانی است که از Google Analytics برای Firebase SDK در برنامه خود استفاده می کنند و می خواهند حالت رضایت را ادغام کنند. برای آشنایی با حالت رضایت، نمای کلی حالت رضایت را بخوانید.
Google Analytics حالت رضایت را برای تنظیم نحوه رفتار SDK شما بر اساس وضعیت رضایت کاربران ارائه می دهد. شما می توانید حالت رضایت را به صورت پایه یا پیشرفته پیاده سازی کنید. اگر مطمئن نیستید که حالت رضایت اولیه یا پیشرفته را اجرا کنید، درباره حالت رضایت اولیه در مقابل پیشرفته بیشتر بدانید و دستورالعملهای شرکت خود را بررسی کنید.
قبل از شروع
قبل از اینکه بتوانید رضایت کاربر را مدیریت کنید، باید موارد زیر را اجرا کنید:
جفتهای کلید-مقدار حالت رضایت را اضافه کنید. کلید نوع رضایت را توصیف می کند و مقدار نشان دهنده وضعیت رضایت است. ارزشها میتوانند true باشند، یعنی رضایت داده شد، یا false ، یعنی رضایت رد شد.
مطابق با بهروزرسانیهای حالت رضایت برای ترافیک در منطقه اقتصادی اروپا (EEA)، مقدار eu_consent_policy را میتوان برای ad_user_data و ad_personalization تنظیم کرد، به این معنی که رضایت فقط برای کاربران مناطق مشمول خطمشی رضایت کاربر اتحادیه اروپا رد میشود.
برای بهروزرسانی مقادیر رضایت پس از راهاندازی برنامه، با روش setConsent تماس بگیرید.
مقدار تنظیم شده توسط روش setConsent تنظیم پیش فرض را لغو می کند و در اجرای برنامه ها باقی می ماند. این مقدار تا زمانی که setConsent دوباره فراخوانی نشود، در آن حالت باقی میماند، حتی اگر کاربر برنامه را ببندد و دوباره باز کند. setConsent فقط پارامترهایی را که شما مشخص کرده اید به روز می کند.
اگر کاربری رضایت قبلی خود را برای Analytics یا ذخیرهسازی آگهی پس بگیرد، Google Analytics همه ویژگیهای کاربر، از جمله رضایت برای ad_personalization را حذف میکند. برای حفظ رضایت کاربر برای شخصیسازی آگهی، مقدار قبلی را برای شخصیسازی آگهی با استفاده از setConsent بازیابی کنید.( سوئیفت | Obj-C ).
مثال زیر روش setConsent را نشان می دهد که مقادیر رضایت متفاوت را به granted به روز می کند:
اگر کاربر تصمیم گرفت رضایت خود را لغو کند، مطمئن شوید که وضعیت رضایت را بر این اساس بهروزرسانی کردهاید
به حالت رضایت نسخه 2 ارتقا دهید
به عنوان بخشی از تعهد مداوم Google به یک اکوسیستم تبلیغات دیجیتال ایمن برای حفظ حریم خصوصی، ما در حال تقویت اجرای سیاست رضایت کاربر اتحادیه اروپا هستیم.
تاریخ آخرین بهروزرسانی 2024-11-18 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2024-11-18 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThis guide helps Firebase developers integrate consent mode to control data collection based on user consent, covering both basic and advanced implementation options.\u003c/p\u003e\n"],["\u003cp\u003eBefore setup, ensure you've implemented the Google Analytics for Firebase SDK and a consent settings banner or CMP.\u003c/p\u003e\n"],["\u003cp\u003eTo set up consent mode, define default consent states in your app's info.plist file and use the \u003ccode\u003esetConsent\u003c/code\u003e method to dynamically update consent values based on user choices.\u003c/p\u003e\n"],["\u003cp\u003eConsent mode v2 introduces two additional parameters, \u003ccode\u003ead_user_data\u003c/code\u003e and \u003ccode\u003ead_personalization\u003c/code\u003e, to comply with Google's updated EU user consent policy, requiring updates to your app's info.plist and consent calls.\u003c/p\u003e\n"],["\u003cp\u003eVerify your implementation by checking the Xcode debug console for consent settings like \u003ccode\u003ead_storage\u003c/code\u003e, \u003ccode\u003eanalytics_storage\u003c/code\u003e, \u003ccode\u003ead_user_data\u003c/code\u003e, and \u003ccode\u003ead_personalization\u003c/code\u003e.\u003c/p\u003e\n"]]],["Developers integrate consent mode with the Google Analytics for Firebase SDK to manage user consent. Key actions involve setting default consent states in the `info.plist` file using keys like `GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE` with `true` or `false` values, which now include `ad_user_data` and `ad_personalization`. The `setConsent` method updates consent after app launch, overriding defaults and persisting across sessions. Upgrading to consent mode v2 requires adding the two new consent parameters to both `info.plist` and `setConsent` calls. Verification is done via the Xcode debug console, checking for specific consent parameters.\n"],null,["# Set up consent mode for apps\n\n\u003e This page is for developers that use the Google Analytics for Firebase SDK in\n\u003e their app and want to integrate consent mode. For an introduction to consent\n\u003e mode, read [Consent mode\n\u003e overview](/tag-platform/security/concepts/consent-mode).\n\nGoogle Analytics offers consent mode to adjust how your SDK behaves based on the\nconsent status of your users. You can implement consent mode in a basic or\nadvanced way. If you aren't sure whether to implement basic or advanced consent\nmode, learn more about [basic versus advanced consent\nmode](/tag-platform/security/concepts/consent-mode#basic-vs-advanced) and check\nwith your company's guidelines. \nAdvanced consent mode Basic consent mode \niOS Android\n| **Important** : Consent mode for apps was updated Oct 30th 2023 and now contains two additional parameters. If you already use consent mode, [upgrade to consent mode v2](#upgrade-consent-v2). Learn more about Google's [Updates to consent mode for traffic in European Economic Area (EEA)](https://support.google.com/tagmanager/answer/13695607).\n\nBefore you begin\n----------------\n\nBefore you can manage user consent, you need to implement:\n\n- [Google Analytics for Firebase SDK](https://firebase.google.com/docs/analytics)\n- A consent settings banner to capture user consent\n\n | **Tip:** If you don't want to implement consent settings yourself, consider using a consent management platform (CMP).\n\nSet up consent mode\n-------------------\n\nTo set up consent mode, you need to:\n\n1. [Set the default consent state](#default-consent).\n\n### Set the default consent state\n\nBy default, no consent mode values are set. To set the default consent state for\nyour app:\n\n1. Open your app's [info.plist](https://developer.apple.com/documentation/bundleresources/information_property_list) file.\n2. Add the consent mode key-value pairs. The key describes the [consent\n type](/tag-platform/security/concepts/consent-mode#consent-types) and the\n value indicates consent state. Values can either be `true`, meaning consent\n was granted, or `false`, meaning consent was denied.\n\n In accordance with the updates to consent mode for traffic in\n European Economic Area (EEA), a value of `eu_consent_policy` can be set\n for `ad_user_data` and `ad_personalization`, meaning consent is denied only\n for users in regions subject to the EU User Consent Policy.\n\n Set the following:\n - `GOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE`\n - `GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE`\n - `GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA`\n - `GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS`\n3. Save your changes. Next, implement the mechanism to update consent values.\n\nFor example, to set all grant consent for all parameters by default: \n\n \u003ckey\u003eGOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE\u003c/key\u003e \u003ctrue/\u003e\n \u003ckey\u003eGOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE\u003c/key\u003e \u003ctrue/\u003e\n \u003ckey\u003eGOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA\u003c/key\u003e \u003ctrue/\u003e\n \u003ckey\u003eGOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS\u003c/key\u003e \u003ctrue/\u003e\n\n### Update consent\n\nTo update consent values after an app has launched, call the\n[`setConsent`](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics#setConsent) method.\n\nThe value set by the `setConsent` method overrides the default setting and\npersists across app executions. The value remains in that state until\n`setConsent` is called again, even if a user closes and reopens the app.\n`setConsent` only updates the parameters you specify.\n\u003e If a user withdraws their previously given consent for Analytics or Ad\n\u003e storage, Google Analytics deletes all user properties, including consent for\n\u003e [`ad_personalization`](https://developers.google.com/tag-platform/security/concepts/consent-mode#consent-type).\n\u003e To preserve the user's consent choice for ad personalization, restore the\n\u003e previous value for ad personalization using `setConsent`\n\u003e\n\u003e ([Swift](https://firebase.google.com/docs/reference/swift/firebaseanalytics/api/reference/Categories/FIRAnalytics(Consent)#setconsent_:)\n\u003e \\| [Obj-C](https://firebase.google.com/docs/reference/ios/firebaseanalytics/api/reference/Classes/FIRAnalytics#+setconsent:))\n\u003e .\n\nThe following example shows the `setConsent` method updating the different\nconsent values to `granted`: \n\n### Swift\n\n Analytics.setConsent([\n .analyticsStorage: .granted,\n .adStorage: .granted,\n .adUserData: .granted,\n .adPersonalization: .granted,\n ])\n\n### Objective-C\n\n [FIRAnalytics setConsent:@{\n FIRConsentTypeAnalyticsStorage : FIRConsentStatusGranted,\n FIRConsentTypeAdStorage : FIRConsentStatusGranted,\n FIRConsentTypeAdUserData : FIRConsentStatusGranted,\n FIRConsentTypeAdPersonalization : FIRConsentStatusGranted,\n }];\n\nIf a user decides to revoke their consent, make sure you update the consent\nstates accordingly\n\n\nUpgrade to consent mode v2\n--------------------------\n\nAs a part of Google's ongoing commitment to a privacy-safe digital advertising\necosystem, we are strengthening the enforcement of our [EU user consent\npolicy](https://www.google.com/about/company/user-consent-policy/).\n\nLearn more about Google's [Updates to consent mode for traffic in European\nEconomic Area (EEA)](https://support.google.com/tagmanager/answer/13695607).\n\nConsent mode users need to send two new parameters in addition to ad storage and\nanalytics storage:\n\n1. Update your app's info.plist to include:\n\n \u003ckey\u003eGOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA\u003c/key\u003e \u003ctrue/\u003e\n \u003ckey\u003eGOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS\u003c/key\u003e \u003ctrue/\u003e\n\n2. Update your consent calls to include the parameters for ad user data and ad\n personalization:\n\n ### Swift\n\n Analytics.setConsent([\n .analyticsStorage: .granted,\n .adStorage: .granted,\n .adUserData: .granted,\n .adPersonalization: .granted,\n ])\n\n ### Objective-C\n\n [FIRAnalytics setConsent:@{\n FIRConsentTypeAnalyticsStorage : FIRConsentStatusGranted,\n FIRConsentTypeAdStorage : FIRConsentStatusGranted,\n FIRConsentTypeAdUserData : FIRConsentStatusGranted,\n FIRConsentTypeAdPersonalization : FIRConsentStatusGranted,\n }];\n\nVerify consent settings\n-----------------------\n\nYou can verify that your consent settings are working as intended by viewing the\nXcode debug console for your app.\n\nFollow these steps:\n\n1. [Enable verbose logging](https://firebase.google.com/docs/analytics/events?platform=ios#view_events_in_the_xcode_debug_console) on your device.\n2. In the Xcode debug console, look for:\n\n - `ad_storage`\n - `analytics_storage`\n - `ad_user_data`\n - `ad_personalization`\n\n For example, if Ad storage are enabled, you'll see the following message: \n\n ad_storage is granted."]]