1

I am looking for a solution on how to detect that my app started inside the pre-launch report. Long story short - I have a game which is already live on google play with unity ads inside and I want to release an update. If I will put my new version on google play it will be checked using pre-launch reports and will generate fake ads impressions. I can't disable ads via unity "operate dashboard" coz it will affect live version users. I don't want to disable pre-launch reposts either, they are very helpful.

So, I am looking for a solution, either code vise or general flow vise.

After a few days of searching the internet, I was able to find two potentials solutions, but neither of them is working.

Solution 1: using this documentation - Firebase and StackOwerflow answer, and this example Unity forum i have come up with this code:

public bool IsTestLab()
{
    using (var actClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
    {
        var context = actClass.GetStatic<AndroidJavaObject>("currentActivity");
        var systemGlobal = new AndroidJavaClass("android.provider.Settings$Global");
        var testLab = systemGlobal.CallStatic<string>("getString", context.Call<AndroidJavaObject>("getContentResolver"), "firebase.test.lab");
        return testLab == "true"
    }
}

Solution 2: Based on Another Firebase doc I have tried also this:

public bool IsTestLab()
{
    return TestLabManager.Instantiate().IsTestingScenario;
}

Can someone share how they are going around this problem?

Thanks in advance!

Artyom
  • 1,065
  • 8
  • 12

2 Answers2

0

For someone who still looking for a solution.

The mistake was that I was reading android.provider.Settings$Global, but this setting is stored in android.provider.Settings$System

So, as a result, this is the correct and working code:

public bool IsTestLab()
{
    using (var actClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
    {
        var context = actClass.GetStatic<AndroidJavaObject>("currentActivity");
        var systemGlobal = new AndroidJavaClass("android.provider.Settings$System");
        var testLab = systemGlobal.CallStatic<string>("getString", context.Call<AndroidJavaObject>("getContentResolver"), "firebase.test.lab");
        return testLab == "true"
    }
}
Artyom
  • 1,065
  • 8
  • 12
0

I did a little bit of digging internally in Google about the specific Ads issue. Sorry it took so long.

Firebase test lab documents its mobile address ranges on this web page. If you use Google mobile advertising it should be fine, Google will already ignore Ad impressions coming from these address ranges. If you use another Ad SDK you might want to contact them and ask them to ignore impressions from these ranges. Then you won't need to modify your app at all.

Nick Fortescue
  • 13,530
  • 1
  • 31
  • 37
  • Thanks for your feedback. Yes, Google/Firebase provides a list of IPs to ignore. I believe those IPs should be blocked on Unity Ads side by default, but this is only one side of a problem. Another side is that if we will ignore ads on Unity, but still display them in pre-launch tests, Google will use them to falsely flag your app as "with issues", because of small text, wrong language.. etc. Basically, it will treat ad as part of your app. So for me, a better approach - not to show ads at all. – Artyom Apr 25 '19 at 07:26