我对 AdMob 的新功能有疑问“同意 SDK” https://developers.google.com/admob/android/eu-consent#consent_sdk; the 整合指南 https://developers.google.com/admob/android/eu-consent说将以下内容放入onCreate...
public class MainActivity extends Activity {
...
@Override
protected void onCreate(Bundle savedInstanceState) {
...
ConsentInformation consentInformation = ConsentInformation.getInstance(context);
String[] publisherIds = {"pub-xxxxxxxxxxxxxxxx"};
consentInformation.requestConsentInfoUpdate(publisherIds, new ConsentInfoUpdateListener() {
@Override
public void onConsentInfoUpdated(ConsentStatus consentStatus) {
// User's consent status successfully updated.
}
@Override
public void onFailedToUpdateConsentInfo(String errorDescription) {
// User's consent status failed to update.
}
});
...
}
...
}
然后拨打电话:
ConsentInformation.getInstance(context).isRequestLocationInEeaOrUnknown()
我遇到的问题是当应用程序first已安装/启动,isRequestLocationInEeaOrUnknown()always返回“假”(我am顺便说一下,在欧洲经济区)。
如果我退出应用程序并重新启动它,它会返回“true” - 这是正确的。如果我然后进入我的设备设置并在我的应用程序上执行“清除数据”并重新启动它,它会再次返回“false”。
显然,这是令人担忧的,因为我向欧洲经济区/瑞士用户展示我自己的自定义同意对话框,而不是我是世界各地的用户。这需要在首次启动时发生。
有趣的是,我尝试拨打电话isRequestLocationInEeaOrUnknown()在我的 AsyncTask 中后台操作方法(我在 onCreate 中关闭这个 ASync),然后它does首次启动时返回“true”,就像在 ASync 的“onPostExecute”方法中对其进行的调用一样。只是在 onCreate 中对其进行的调用不会(在异步启动之前或之后)。
我知道现在还为时过早,但是有人偶然发现过类似的问题吗?
你必须打电话isRequestLocationInEeaOrUnknown()
after onConsentInfoUpdated
回调被调用。
该值由异步检索requestConsentInfoUpdate()
,因此它在第一次启动时不正确,但随后会被缓存,因此在第二次启动时您将获得正确的值。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)