如何使用新的Android统一消息平台SDK请求非个性化的AdMob广告

如何解决如何使用新的Android统一消息平台SDK请求非个性化的AdMob广告

我目前正在使用Google的consent-library(不推荐使用)来请求欧洲用户的个性化广告同意。该文档指定,如果用户的同意状态已设置为PERSONALIZED或NON_PERSONALIZED,则可以forward consent to the Google Mobile Ads SDK进行以下操作:

Bundle extras = new Bundle();
extras.putString("npa","1");

AdRequest request = new AdRequest.Builder()
    .addNetworkExtrasBundle(AdMobAdapter.class,extras)
    .build();

现在,我想迁移到新的Unified Messaging Platform SDK for Android。该文档非常简单,但是仅说明了如何获得同意,而不说明如何使用同意。这是否意味着在使用新的Android版UMP SDK时,当我们为不同意个性化广告的用户请求AdMob广告时,我们不再需要将"npa"设置为"1"了吗?


EDIT 2020年8月25日

昨天我发现了这个conversation,来自Mobile Ads SDK团队的人回答了我在这里提出的相同问题。他说:

我们的SDK将保留通过 npa = 1 的旧版“通过同意”,直到另行通知为止。


EDIT 2020年8月31日

我开始了一个new conversation,在这里我问的是与本文中相同的问题,但是没有得到任何答复。

解决方法

借助新的统一消息平台,Google可以作为Consent Managing Platform使用。这些CMP使用TCF字符串存储用户同意首选项。 Google检查此TCF字符串以查看可以展示哪些广告;

根据Google documentation

当满足以下所有条件时,

Google将投放个性化广告:

  1. 最终用户授予Google同意存储和/或访问 设备上的信息
  2. 创建个性化的广告资料
  3. 选择个性化广告

并建立了Google的合法权益(或同意,即发布者将其CMP配置为要求该出价):

  1. 选择基本广告
  2. 衡量广告效果
  3. 应用市场研究以生成受众见解
  4. 开发和改进产品

如果不满足个性化广告的同意要求,则当满足以下所有条件时,Google将投放非个性化广告

  1. 在设备上存储和/或访问信息

建立了合法利益(或同意,即发布者将其CMP配置为请求CMP):

  1. 选择基本广告
  2. 衡量广告效果
  3. 应用市场研究以生成受众见解
  4. 开发和改进产品
  5. 在供应商列表中启用Google。

10月20日更新: 显然,不再需要3,4,5来显示用于提供此信息的非个人广告,例如@Georg。

如果以上条件均未满足,则Google不会展示广告。

我希望这能回答您的问题,但是如果您需要更多信息,请告诉我!

,

只要记住这些句子:

永不放弃,杯子总是装满一半:-)->要乐观!

因此,将不再有“解决方案”来改变欧洲的有效规定。我们可以做的是这样:

当用户在资金选择表中单击“同意”或单击“提交”后,如果关闭对话框,某些参数将保存在android的默认共享首选项中!在IOS上发生了同样的事情(因此每个人都可以快速轻松地编写此解决方案

就像提供有限应用程序的“我们”权利之前一样。这意味着像在您可以提供带有限制的精简版本和要购买的完整版本之前一样。

所以我们能做的就是读取首选键。

此处描述了透明度和同意框架的首选项键: https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md#in-app-details

我们需要以下偏好键才能读取(Android或IOS):

IABTCF_PurposeLegitimateInterests

IABTCF_VendorConsents

IABTCF_PurposeConsents

因此,根据这些值,我们可以检查在关闭表单后是否投放广告或“不”投放广告。

然后,您可以阻止应用中的重要选项,并可能显示一个对话框:

“广告已被禁用。您正在使用该应用的简易版。您可以改变主意或购买专业版等,等等。”

->也许在解释“启用广告”后添加按钮,然后再次显示该表格或“购买专业版”

这取决于您在这里做什么!

我的课是在kotlin或Java中!

您的工作: 将Google的UMP SDK放到您的依赖中,并在admob帐户中为您的应用设置资金选择!然后编写例程以设置资金选择表格。

在资金选择中,仅添加“ Google”作为供应商!

https://developers.google.com/admob/ump/android/quick-start

您仍然需要自己编写很多程序才能使一切正常运行,但是无论是否投放广告,此类都将至少帮助您获取信息。另外,您必须告诉自己一切如何工作以更深入地了解这一点。

记住!!!

始终使用admob中的测试ID进行测试!切勿使用生产ID,否则您可以 麻烦您的帐户!仅当您想先进行测试时,才在admob中使用测试ID创建一个新的测试应用!

如何使用课程:

Consentfunctions consentfunction; 


consentfunction = new Consentfunctions(this);



// Check if Ads are serving

if (consentfunction.AdsAreServing()) {

// No need to do anything because everything is fine

} else {

// Decide what to do here. Block important functions of your app
//  and open a help page with explanations etc. etc


}

Java代码:

public class ConsentFunctions {

private ConsentInformation consentInformation;

SharedPreferences.Editor editor;


  private Context mContext;



private String consinfosaved;

private String vendorconsent;

private SharedPreferences preferences;

private String LegitimateInterests;


public ConsentFunctions(Context context){

    mContext = context;


    preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
    



    consentInformation = UserMessagingPlatform.getConsentInformation(mContext);


}



public Boolean AdsAreServing() {

    vendorconsent = preferences.getString("IABTCF_VendorConsents","");
    LegitimateInterests = preferences.getString("IABTCF_PurposeLegitimateInterests","");


    // Not required = not in europe -- return true because everything is fine !
    if (consentInformation.getConsentStatus() == ConsentInformation.ConsentStatus.NOT_REQUIRED) {
        return true;
    }


    Boolean vendoractive = vendorconsent.contains("1");
    consinfosaved = preferences.getString("IABTCF_PurposeConsents","0");

    switch (consinfosaved) {


        case "1011":    // Personal 1 - rest legitimate interest
        case "1111111011":  // Personal 2
        case "1111001011":  // Personal 3
        case "1000001011":  // Non personal ok
        case "1100001011":  // Non Peronal ok
        case "11":   // Non Personal ok - rest is legitimate interest
        case    "1111001001":
        case "1":  // Non personalized


        {

            // Check also if vendor is activated
            if (!vendoractive) {
                return false;

            }
            else {

                // Legitimate must be always =  0100111011 and vendor contains 1
                if (LegitimateInterests.equals("0100111011") || LegitimateInterests.equals("0100001011"))
                return true;
                else
                    return false;

            }

        }


        default: {


            return false;



        }



    }


}


}

科特琳代码:

class ConsentFunctionsKotlin(private val mContext: Context) {


private val consentInformation: ConsentInformation
var editor: SharedPreferences.Editor


private var consinfosaved: String? = null
private var vendorconsent: String? = null
private val preferences: SharedPreferences
private var LegitimateInterests: String? = null



init {
    preferences = PreferenceManager.getDefaultSharedPreferences(mContext)
   
    consentInformation = UserMessagingPlatform.getConsentInformation(mContext)
}





fun AdsAreServing(): Boolean {
    vendorconsent = preferences.getString("IABTCF_VendorConsents","")
    LegitimateInterests = preferences.getString("IABTCF_PurposeLegitimateInterests","")


    // Not required = not in europe -- return true because everything is fine !
    if (consentInformation.consentStatus == ConsentInformation.ConsentStatus.NOT_REQUIRED) {
        return true
    }


    val vendoractive = vendorconsent!!.contains("1")
    consinfosaved = preferences.getString("IABTCF_PurposeConsents","0")

    return when (consinfosaved) {
        "1111001001","1011","1111111011","1111001011","1000001011","1100001011","11","1" -> {


            // Check also if vendor is activated
            if (!vendoractive) {
                false
            } else {

                // Legitimate must be always =  0100111011 and vendor contains 1
                if (LegitimateInterests == "0100111011" || LegitimateInterests == "0100001011") true else false
            }
        }
        else -> {
            false
        }
    }


}

}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-