diff --git a/source/plugin/Assets/GoogleMobileAds/Editor/GoogleMobileAdsSettings.cs b/source/plugin/Assets/GoogleMobileAds/Editor/GoogleMobileAdsSettings.cs index 7fec89274..0e17f3dfb 100644 --- a/source/plugin/Assets/GoogleMobileAds/Editor/GoogleMobileAdsSettings.cs +++ b/source/plugin/Assets/GoogleMobileAds/Editor/GoogleMobileAdsSettings.cs @@ -53,6 +53,18 @@ internal static GoogleMobileAdsSettings LoadInstance() [SerializeField] private string userLanguage = "en"; + [SerializeField] + private bool defaultAllowAdStorage; + + [SerializeField] + private bool defaultAllowAdPersonalization; + + [SerializeField] + private bool defaultAllowAdUserData; + + [SerializeField] + private bool defaultAllowAnalyticsStorage; + public string GoogleMobileAdsAndroidAppId { get { return adMobAndroidAppId; } @@ -101,5 +113,29 @@ public string UserLanguage set { userLanguage = value; } } + + public bool DefaultAllowAdStorage + { + get { return defaultAllowAdStorage; } + set { defaultAllowAdStorage = value; } + } + + public bool DefaultAllowAdPersonalization + { + get { return defaultAllowAdPersonalization; } + set { defaultAllowAdPersonalization = value; } + } + + public bool DefaultAllowAdUserData + { + get { return defaultAllowAdUserData; } + set { defaultAllowAdUserData = value; } + } + + public bool DefaultAllowAnalyticsStorage + { + get { return defaultAllowAnalyticsStorage; } + set { defaultAllowAnalyticsStorage = value; } + } } } diff --git a/source/plugin/Assets/GoogleMobileAds/Editor/GoogleMobileAdsSettingsEditor.cs b/source/plugin/Assets/GoogleMobileAds/Editor/GoogleMobileAdsSettingsEditor.cs index a5172b232..f2d0f4235 100644 --- a/source/plugin/Assets/GoogleMobileAds/Editor/GoogleMobileAdsSettingsEditor.cs +++ b/source/plugin/Assets/GoogleMobileAds/Editor/GoogleMobileAdsSettingsEditor.cs @@ -15,6 +15,10 @@ public class GoogleMobileAdsSettingsEditor : UnityEditor.Editor SerializedProperty _disableOptimizeAdLoading; SerializedProperty _userLanguage; SerializedProperty _userTrackingUsageDescription; + SerializedProperty _defaultAllowAdStorage; + SerializedProperty _defaultAllowAdPersonalization; + SerializedProperty _defaultAllowAdUserData; + SerializedProperty _defaultAllowAnalyticsStorage; // Using an ordered list of languages is computationally expensive when trying to create an // array out of them for purposes of showing a dropdown menu. Care should be taken to ensure @@ -40,6 +44,10 @@ public void OnEnable() _userLanguage = serializedObject.FindProperty("userLanguage"); _userTrackingUsageDescription = serializedObject.FindProperty("userTrackingUsageDescription"); + _defaultAllowAdStorage = serializedObject.FindProperty("defaultAllowAdStorage"); + _defaultAllowAdPersonalization = serializedObject.FindProperty("defaultAllowAdPersonalization"); + _defaultAllowAdUserData = serializedObject.FindProperty("defaultAllowAdUserData"); + _defaultAllowAnalyticsStorage = serializedObject.FindProperty("defaultAllowAnalyticsStorage"); selectedIndex = Array.IndexOf(languageCodes, _userLanguage.stringValue); selectedIndex = selectedIndex >= 0 ? selectedIndex : 0; @@ -99,7 +107,6 @@ public override void OnInspectorGUI() MessageType.Info); } - EditorGUILayout.PropertyField( _disableOptimizeInitialization, new GUIContent(localization.ForKey("DISABLE_OPTIMIZE_INITIALIZATION_SETTING"))); @@ -134,6 +141,38 @@ public override void OnInspectorGUI() EditorGUILayout.HelpBox(localization.ForKey("USER_TRACKING_USAGE_DESCRIPTION_HELPBOX"), MessageType.Info); + EditorGUILayout.Separator(); + + // Default Consent State + EditorGUIUtility.labelWidth = 345.0f; + EditorGUILayout.LabelField(localization.ForKey("DEFAULT_CONSENT_STATE_LABEL"), + EditorStyles.boldLabel); + EditorGUI.indentLevel++; + + EditorGUILayout.PropertyField( + _defaultAllowAdStorage, + new GUIContent(localization.ForKey("DEFAULT_CONSENT_AD_STORAGE_SETTING"))); + EditorGUILayout.HelpBox(localization.ForKey("DEFAULT_CONSENT_AD_STORAGE_HELPBOX"), + MessageType.Info); + + EditorGUILayout.PropertyField( + _defaultAllowAdPersonalization, + new GUIContent(localization.ForKey("DEFAULT_CONSENT_AD_PERSONALIZATION_SETTING"))); + EditorGUILayout.HelpBox(localization.ForKey("DEFAULT_CONSENT_AD_PERSONALIZATION_HELPBOX"), + MessageType.Info); + + EditorGUILayout.PropertyField( + _defaultAllowAdUserData, + new GUIContent(localization.ForKey("DEFAULT_CONSENT_AD_USER_DATA_SETTING"))); + EditorGUILayout.HelpBox(localization.ForKey("DEFAULT_CONSENT_AD_USER_DATA_HELPBOX"), + MessageType.Info); + + EditorGUILayout.PropertyField( + _defaultAllowAnalyticsStorage, + new GUIContent(localization.ForKey("DEFAULT_CONSENT_ANALYTICS_STORAGE_SETTING"))); + EditorGUILayout.HelpBox(localization.ForKey("DEFAULT_CONSENT_ANALYTICS_STORAGE_HELPBOX"), + MessageType.Info); + EditorGUI.indentLevel--; EditorGUILayout.Separator(); diff --git a/source/plugin/Assets/GoogleMobileAds/Editor/ManifestProcessor.cs b/source/plugin/Assets/GoogleMobileAds/Editor/ManifestProcessor.cs index 6b4cdead1..9f936728c 100644 --- a/source/plugin/Assets/GoogleMobileAds/Editor/ManifestProcessor.cs +++ b/source/plugin/Assets/GoogleMobileAds/Editor/ManifestProcessor.cs @@ -54,6 +54,15 @@ public class ManifestProcessor : IPreprocessBuild private const string METADATA_UNITY_VERSION = "com.google.unity.ads.UNITY_VERSION"; // LINT.ThenChange(//depot/google3/javatests/com/google/android/gmscore/integ/modules/admob/tests/robolectric/src/com/google/android/gms/ads/nonagon/signals/StaticDeviceSignalSourceTest.java) + private const string METADATA_DEFAULT_ALLOW_AD_STORAGE = + "google_analytics_default_allow_ad_storage"; + private const string METADATA_DEFAULT_ALLOW_AD_PERSONALIZATION = + "google_analytics_default_allow_ad_personalization_signals"; + private const string METADATA_DEFAULT_ALLOW_AD_USER_DATA = + "google_analytics_default_allow_ad_user_data"; + private const string METADATA_DEFAULT_ALLOW_ANALYTICS_STORAGE = + "google_analytics_default_allow_analytics_storage"; + private XNamespace ns = "http://schemas.android.com/apk/res/android"; public int callbackOrder { get { return 0; } } @@ -146,6 +155,30 @@ public void OnPreprocessBuild(BuildTarget target, string path) METADATA_UNITY_VERSION, Application.unityVersion); + SetMetadataElement(elemApplication, + metas, + METADATA_DEFAULT_ALLOW_AD_STORAGE, + instance.DefaultAllowAdStorage, + true); + + SetMetadataElement(elemApplication, + metas, + METADATA_DEFAULT_ALLOW_AD_PERSONALIZATION, + instance.DefaultAllowAdPersonalization, + true); + + SetMetadataElement(elemApplication, + metas, + METADATA_DEFAULT_ALLOW_AD_USER_DATA, + instance.DefaultAllowAdUserData, + true); + + SetMetadataElement(elemApplication, + metas, + METADATA_DEFAULT_ALLOW_ANALYTICS_STORAGE, + instance.DefaultAllowAnalyticsStorage, + true); + elemManifest.Save(manifestPath); } diff --git a/source/plugin/Assets/GoogleMobileAds/Editor/PListProcessor.cs b/source/plugin/Assets/GoogleMobileAds/Editor/PListProcessor.cs index 60b5f639d..bb249a458 100644 --- a/source/plugin/Assets/GoogleMobileAds/Editor/PListProcessor.cs +++ b/source/plugin/Assets/GoogleMobileAds/Editor/PListProcessor.cs @@ -35,6 +35,17 @@ public static class PListProcessor private const string SKADNETWORKS_FILE_NAME = "GoogleMobileAdsSKAdNetworkItems.xml"; + private const string KEY_DEFAULT_ALLOW_AD_STORAGE = "GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE"; + + private const string KEY_DEFAULT_ALLOW_AD_PERSONALIZATION = + "GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS"; + + private const string KEY_DEFAULT_ALLOW_AD_USER_DATA = + "GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA"; + + private const string KEY_DEFAULT_ALLOW_ANALYTICS_STORAGE = + "GOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE"; + [PostProcessBuild] public static void OnPostProcessBuild(BuildTarget buildTarget, string path) { @@ -72,6 +83,14 @@ public static void OnPostProcessBuild(BuildTarget buildTarget, string path) plist.root.SetString("GADUUnityVersion", unityVersion); } + // Set default consent values + plist.root.SetBoolean(KEY_DEFAULT_ALLOW_AD_STORAGE, instance.DefaultAllowAdStorage); + plist.root.SetBoolean(KEY_DEFAULT_ALLOW_AD_PERSONALIZATION, + instance.DefaultAllowAdPersonalization); + plist.root.SetBoolean(KEY_DEFAULT_ALLOW_AD_USER_DATA, instance.DefaultAllowAdUserData); + plist.root.SetBoolean(KEY_DEFAULT_ALLOW_ANALYTICS_STORAGE, + instance.DefaultAllowAnalyticsStorage); + File.WriteAllText(plistPath, plist.WriteToString()); } diff --git a/source/plugin/Assets/GoogleMobileAds/Editor/gma_settings_editor_localization_data.json b/source/plugin/Assets/GoogleMobileAds/Editor/gma_settings_editor_localization_data.json index c15cfe573..021a09aab 100644 --- a/source/plugin/Assets/GoogleMobileAds/Editor/gma_settings_editor_localization_data.json +++ b/source/plugin/Assets/GoogleMobileAds/Editor/gma_settings_editor_localization_data.json @@ -59,6 +59,42 @@ "KEY_USER_TRACKING_USAGE_DESCRIPTION_SETTING": { "en": "User Tracking Usage Description", "fr": "Description de l'utilisation du suivi des utilisateurs" + }, + "KEY_DEFAULT_CONSENT_STATE_LABEL": { + "en": "Default consent state", + "fr": "État de consentement par défaut" + }, + "KEY_DEFAULT_CONSENT_AD_STORAGE_SETTING": { + "en": "Default allow ad storage", + "fr": "Défaut autoriser le stockage d'annonces" + }, + "KEY_DEFAULT_CONSENT_AD_STORAGE_HELPBOX": { + "en": "Enables storage, such as cookies (web) or device identifiers (apps), related to advertising.", + "fr": "Permet le stockage lié à la publicité, comme les cookies (web) ou les identifiants d'appareil (applications)." + }, + "KEY_DEFAULT_CONSENT_AD_PERSONALIZATION_SETTING": { + "en": "Default allow ad personalization", + "fr": "Défaut autoriser la personnalisation des annonces" + }, + "KEY_DEFAULT_CONSENT_AD_PERSONALIZATION_HELPBOX": { + "en": "Sets consent for personalized advertising.", + "fr": "Définit le consentement pour la publicité personnalisée." + }, + "KEY_DEFAULT_CONSENT_AD_USER_DATA_SETTING": { + "en": "Default allow ad user data", + "fr": "Défaut autoriser les données publicitaires de l'utilisateur" + }, + "KEY_DEFAULT_CONSENT_AD_USER_DATA_HELPBOX": { + "en": "Sets consent for sending user data to Google for online advertising purposes.", + "fr": "Définit le consentement pour l'envoi de données utilisateur à Google à des fins de publicité en ligne." + }, + "KEY_DEFAULT_CONSENT_ANALYTICS_STORAGE_SETTING": { + "en": "Default allow analytics storage", + "fr": "Défaut autoriser le stockage des données analytiques" + }, + "KEY_DEFAULT_CONSENT_ANALYTICS_STORAGE_HELPBOX": { + "en": "Enables storage, such as cookies (web) or device identifiers (apps), related to analytics, for example, visit duration.", + "fr": "Permet le stockage lié aux données analytiques, comme la durée des visites, les cookies (Web) ou les identifiants d'appareil (applications)." } } }