简体   繁体   English

在Unity中检测Google Play发布前报告

[英]Detect Google Play pre-launch report in Unity

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. 长话短说-我有一个游戏已经在Google Play上直播,里面装有统一广告,我想发布一个更新。 If I will put my new version on google play it will be checked using pre-launch reports and will generate fake ads impressions. 如果我将新版本放到Google Play上,则会使用发布前的报告进行检查,并会产生虚假的广告展示次数。 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: 解决方法1:使用该资料- 火力地堡StackOwerflow答案 ,而这个例子团结论坛,我想出了这样的代码:

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: 解决方案2:根据另一个Firebase文档,我也尝试过这样做:

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

Can someone share how they are going around this problem? 有人可以分享他们如何解决这个问题吗?

Thanks in advance! 提前致谢!

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 错误是我正在读取android.provider.Settings$Global ,但是此设置存储在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"
    }
}

I did a little bit of digging internally in Google about the specific Ads issue. 我在Google内部做了一些关于特定广告问题的挖掘。 Sorry it took so long. 抱歉,花了这么长时间。

Firebase test lab documents its mobile address ranges on this web page . Firebase测试实验室在此网页上记录了其移动地址范围。 If you use Google mobile advertising it should be fine, Google will already ignore Ad impressions coming from these address ranges. 如果您使用Google移动广告就可以了,那么Google已经忽略了来自这些地址范围的广告展示。 If you use another Ad SDK you might want to contact them and ask them to ignore impressions from these ranges. 如果您使用其他广告SDK,则可能需要与他们联系,并要求他们忽略这些范围内的展示。 Then you won't need to modify your app at all. 然后,您根本不需要修改您的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM