Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -99,7 +107,6 @@ public override void OnInspectorGUI()
MessageType.Info);
}


EditorGUILayout.PropertyField(
_disableOptimizeInitialization,
new GUIContent(localization.ForKey("DISABLE_OPTIMIZE_INITIALIZATION_SETTING")));
Expand Down Expand Up @@ -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();

Expand Down
33 changes: 33 additions & 0 deletions source/plugin/Assets/GoogleMobileAds/Editor/ManifestProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; } }
Expand Down Expand Up @@ -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);
}

Expand Down
19 changes: 19 additions & 0 deletions source/plugin/Assets/GoogleMobileAds/Editor/PListProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)."
}
}
}