Ad Consent Android App - 如何清除以便重试

Ad Consent Android App - How to Clear so can try again

我已经按照页面为欧洲人编写了广告同意书:

https://developers.google.com/admob/android/eu-consent

它似乎工作得很好,但我想清除我的选择,所以它认为我还没有做出选择,所以我可以重新测试。 如何做到这一点?

您可以卸载并重新安装该应用程序,也可以前往 "Settings -> Apps & Notifications -> Your App -> Storage -> Clear Data"

清除设备或模拟器上的应用程序数据

关于用户选择的Consent SDK信息存储在SharedPreferences中,会通过清除数据或重新安装应用来清除。

如果您希望以编程方式执行此操作,您可以通过调用

手动将同意状态重置为 UNKNOWN
ConsentInformation.getInstance(context).setConsentStatus(ConsentStatus.UNKNOWN);

至少应该在下次启动时触发同意对话框(取决于您调用它相对于对话框启动的位置)。

回答永远不晚,这可以帮助到需要它的人。

Key Point: It is important that the user is able to change or revoke the consent they have provided at any time.

要撤销同意并重新开始,只需在您认为方便的地方调用此函数即可。

ConsentInformation consentInformation = ConsentInformation.getInstance(Context);
consentInformation.reset();