Search Unity

[solved] Unity Ads And Google Play Pre-launch Tests

Discussion in 'Unity Ads & User Acquisition' started by lvkae, Apr 9, 2019.

  1. lvkae

    lvkae

    Joined:
    Mar 20, 2014
    Posts:
    8
    Hello Community!

    I have a question regarding Unity Ads and Google Play pre-launch tests. In pre-launch reports, I see screenshots with real ads. Which I believe is not good, as I generate fake impressions. How can I solve this without disabling those test (they are pretty good), and without completely stopping unit ads engine via "operate dashboard". I see option test devices, but I don't understand where to get Advertising ID and if it is even possible to block google test devices this way.

    Thanks in advance for any help!
     
  2. lvkae

    lvkae

    Joined:
    Mar 20, 2014
    Posts:
    8
    Just to clarify, I am not talking about development time. It's completely fine to use test mode during development. I am talking about rolling out updates for already live game which is using rewarded ads, for example. I can't disable ads entirely via the operating dashboard, coz it will break user experience who will try to use rewarded ads during this time. Same time I need to upload the new version on google play without test mode to make it public after internal/alpha tests.

    Is it correct flow or I am doing something wrong here?
     
  3. lvkae

    lvkae

    Joined:
    Mar 20, 2014
    Posts:
    8
    If someone would have the same issue, I have finally made it work using this code:

    Code (CSharp):
    1. public bool IsTestLab()
    2. {
    3.     using (var actClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
    4.     {
    5.         var context = actClass.GetStatic<AndroidJavaObject>("currentActivity");
    6.         var systemGlobal = new AndroidJavaClass("android.provider.Settings$System");
    7.         var testLab = systemGlobal.CallStatic<string>("getString", context.Call<AndroidJavaObject>("getContentResolver"), "firebase.test.lab");
    8.         return testLab == "true"
    9.     }
    10. }
    It returns `true` if started inside Google Play pre-launch tests.
     
  4. wendersonjs

    wendersonjs

    Joined:
    Nov 2, 2021
    Posts:
    2
    Much appreciated. I will insert that on my codes
     
  5. wendersonjs

    wendersonjs

    Joined:
    Nov 2, 2021
    Posts:
    2
    For those using Kotlin, I found that piece in the Firebase documentation:


    val testLabSetting = Settings.System.getString(contentResolver, "firebase.test.lab")
    if ("true" == testLabSetting) {
    // Do something when running in Test Lab
    // ...
    test_mode = true

    }