Beispiel #1
0
 static public void RevokeConsent()
 {
     TopAds.RevokeConsent();
     TopAnalytics.InitWithConsent(false);
     if (!PlayerPrefs.HasKey("consent") || PlayerPrefs.GetInt("consent") != 0)
     {
         PlayerPrefs.SetInt("consent", 0);
         PlayerPrefs.Save();
     }
 }
Beispiel #2
0
    public static void SetGDPRConsent(bool gdprConsent)
    {
        TopAnalytics.InitWithConsent(gdprConsent);

        TopAds.InitializeSDK();
        if (gdprConsent)
        {
            TopAds.GrantConsent();
        }
        else
        {
            TopAds.RevokeConsent();
        }
    }
Beispiel #3
0
 // Before calling methods in TopAds and TopAnalytics you must call their init methods
 // TopAds requires the TopAds prefab to be created in the scene
 // You also need to collect user GDPR consent and pass that boolean value to TopAds and TopAnalytics
 // You can collect this consent by displaying a popup to the user at the start of the game and then storing that value for future use
 public static void StartGame()
 {
     UnityEngine.Assertions.Assert.IsTrue(RGPDManager.RgpdConsentalue.HasValue);
     TopAds.InitializeSDK();
     TopAnalytics.InitWithConsent(RGPDManager.RgpdConsentalue.Value);
     if (RGPDManager.RgpdConsentalue.Value)
     {
         TopAds.GrantConsent();
     }
     else
     {
         TopAds.RevokeConsent();
     }
     // Track in TopAnalytics that a game has started
     TopAnalytics.TrackEvent(GAME_STARTED_EVENT);
     TopAds.OnAdShownEvent += TopAds_OnAdShownEvent;
 }
Beispiel #4
0
    // TODO Before calling methods in TopAds and TopAnalytics you must call their init methods
    // TopAds requires the TopAds prefab to be created in the scene
    // TODO You also need to collect user GDPR consent and pass that boolean value to TopAds and TopAnalytics
    // You can collect this consent by displaying a popup to the user at the start of the game and then storing that value for future use


    /**
     * @requires calling the Initialize method first
     */
    public static void StartGame()
    {
        /**
         * GDPR CONSENT
         * We Asynchronously Collect this consent by displaying a popup to the user
         * we pass the consent to the SDK in the initialization Method alongslide the app ID
         * @see An example at [MainCanvasScript.cs]
         */

        // use the ConsentGiven to init TopAnalytics
        TopAnalytics.InitWithConsent(ConsentGiven);

        // init TopAds
        TopAds.InitializeSDK();


        // Grant/Revoke TopAds based on consentGiven value
        if (ConsentGiven)
        {
            TopAds.GrantConsent();
        }
        else
        {
            TopAds.RevokeConsent();
        }

        // Track in TopAnalytics that a game has started
        TopAnalytics.TrackEvent("Game_started");


        // Delegate TopAds events to listeners to ensure that we always have an ad ready :)
        TopAds.OnAdLoadedEvent += OnAdLoadedEvent;
        TopAds.OnAdFailedEvent += OnAdFailedEvent;
        TopAds.OnAdShownEvent  += OnAdShownEvent;


        // we request an ad to prepare for the ShowAd Event :)
        TopAds.RequestAd(appAdUnitID);


        gamesSinceLastAd++;
    }