Exemplo n.º 1
0
 /// <summary>
 /// Saves the give app consent to PlayerPrefs as JSON using the demo storage key.
 /// </summary>
 /// <param name="consent">Consent.</param>
 public static void SaveDemoAppConsent(DemoAppConsent consent)
 {
     if (consent != null)
     {
         consent.Save(DemoStorageKey);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Forwards the consent to relevant modules of EM.
        /// </summary>
        /// <param name="consent">Consent.</param>
        /// <remarks>
        /// In a real-world app, you'd want to write similar method
        /// to forward the obtained consent not only to relevant EM modules
        /// and services, but also to other relevant 3rd-party SDKs in your app.
        public static void ApplyDemoAppConsent(DemoAppConsent consent)
        {
            // Forward the consent to the Advertising module.
            if (consent.advertisingConsent == ConsentStatus.Granted)
            {
                Advertising.GrantDataPrivacyConsent();
            }
            else if (consent.advertisingConsent == ConsentStatus.Revoked)
            {
                Advertising.RevokeDataPrivacyConsent();
            }

            // Forward the consent to the Notifications module.
            if (consent.notificationConsent == ConsentStatus.Granted)
            {
                Notifications.GrantDataPrivacyConsent();
            }
            else if (consent.notificationConsent == ConsentStatus.Revoked)
            {
                Notifications.RevokeDataPrivacyConsent();
            }

            // Here you can forward the consent to other relevant 3rd-party services if needed...
        }
Exemplo n.º 3
0
        void Awake()
        {
            // Checks if we're in EEA region.
            Privacy.IsInEEARegion(result =>
            {
                mIsInEEARegion = result == EEARegionStatus.InEEA;
            });

            // Fetch Unity Analytics URL for use in case the consent dialog
            // is shown from the demo buttons.
            if (string.IsNullOrEmpty(UnityAnalyticsOptOutURL))
            {
                FetchUnityAnalyticsOptOutURL(null, null);
            }

            // If we think consent is not needed for our app (or the current device
            // is not in EEA region), we can just
            // go ahead and initialize EM runtime as normal.
            if (!shouldRequestConsent)
            {
                if (RuntimeManager.IsInitialized())
                {
                    RuntimeManager.Init();
                }

                return;
            }

            // Here's the case where we want to ask for consent before initializing.
            // Before initialization we need to check
            // if we have user's data privacy consent or not.
            DemoAppConsent consent = DemoAppConsent.LoadDemoAppConsent();

            // If there's a stored consent:
            // the implementation of this demo app guarantees
            // that this consent was forwarded to relevant modules before it was stored.
            // These modules would have automatically stored their own consent persistently
            // and use that consent during initialization.
            // In short we'll just go ahead with initializing the EM runtime.
            if (consent != null)
            {
                if (!RuntimeManager.IsInitialized())
                {
                    RuntimeManager.Init();
                }

                return;
            }

            // If there's no consent:
            // We'll show the demo consent dialog and ask the user for data privacy consent
            // before initializing EM runtime. In a real-world app, you would also want
            // to postpone the initialization of any 3rd-party SDK that requires consent until
            // such consent is obtained via the consent dialog.
            // ---
            // First fetch the UnityAds opt-out URL which is needed for the consent dialog.
            // Once it's fetched, we'll show the dialog. Once the dialog completes, we'll
            // initialize EM runtime, see DemoDialog_Completed event handler below.
            FetchUnityAnalyticsOptOutURL(
                (url) =>
            {
                // Success: show the demo consent dialog in English.
                ShowDemoConsentDialog(false);
            },
                (error) =>
            {
                // Failure: also show the demo consent dialog in English.
                // The toogle for Unity Analytics will automatically update
                // its description to reflect that the URL is not available.
                ShowDemoConsentDialog(false);
            });
        }
Exemplo n.º 4
0
 public static void SaveDemoAppConsent(DemoAppConsent consent)
 {
 }
Exemplo n.º 5
0
 public static void ApplyDemoAppConsent(DemoAppConsent consent)
 {
 }