问题描述
我已经获得GDPR同意的Android同意SDK的工作版本。在物理和仿真设备上运行良好。对于仿真设备,SDK应该识别出它是仿真器,而不一定带有设备ID的显式addTestDevice
()。但是,似乎使用API 30无法识别仿真设备。解决方法是,Logcat标识我明确传递给addTestDevice
()的仿真器设备ID。下面是我的代码,就像我说的那样,它最适合API29。API30不能隐式识别模拟器。我在API 30上同时尝试了Pixel 3和Pixel XL。我想知道是否还有其他人看到过此消息,或者我应该在API 30中了解一些新知识。谢谢!
fun initializeGDPR(responseCallBack: (status:GDPRConsentResponse) -> Unit) {
val consentinformation = Consentinformation.getInstance(context)
if (ENABLE_TEST_EEA_CONSENT)
enableEEATestDevices(consentinformation)
consentinformation.requestConsentInfoUpdate(arrayOf(context.getString(R.string.admob_publisher_id)),object : ConsentInfoUpdateListener {
override fun onConsentInfoUpdated(consentStatus: ConsentStatus) {
Log.d("ConsentHelper","initializeGDPR:onConsentInfoUpdated: $consentStatus")
//Is user if European Union or request location is UnkNown
if(consentinformation.isRequestLocationInEeaOrUnkNown) {
Log.d("ConsentHelper","initializeGDPR:isRequestLocationInEeaOrUnkNown: true");
// If the returned ConsentStatus is PERSONALIZED or NON_PERSONALIZED,the user has already provided consent. Call back to initial calling routine to habdle
// If the returned ConsentStatus is UNKNowN,load form to get consent
when (consentStatus) {
ConsentStatus.UNKNowN -> displayGDPRConsentForm(responseCallBack)
ConsentStatus.PERSONALIZED -> {
consentResponse = GDPRConsentResponse.SHOW_PERSONAL
responseCallBack(consentResponse)
}
ConsentStatus.NON_PERSONALIZED -> {
consentResponse = GDPRConsentResponse.SHOW_NON_PERSONAL
responseCallBack(consentResponse)
}
}
} else {
Log.d("ConsentHelper","initializeGDPR:isRequestLocationInEeaOrUnkNown: false")
isEEA = false
consentResponse = GDPRConsentResponse.UNKNowN
responseCallBack(consentResponse)
}
}
override fun onFailedToUpdateConsentInfo(errorDescription: String) {
Log.d("ConsentHelper","initializeGDPR:onFailedToUpdateConsentInfo: $errorDescription");
errorString = errorDescription
consentResponse = GDPRConsentResponse.UNKNowN
responseCallBack(consentResponse)
}
})
}
private fun enableEEATestDevices(consentinformation:Consentinformation) {
consentinformation.debugGeography = DebugGeography.DEBUG_GEOGRAPHY_EEA
consentinformation.addTestDevice(CONSENT_TEST_DEVICES_1)
consentinformation.addTestDevice(CONSENT_TEST_DEVICES_2)
consentinformation.addTestDevice(CONSENT_TEST_DEVICES_3)
consentinformation.addTestDevice(CONSENT_TEST_DEVICES_4)
consentinformation.addTestDevice(CONSENT_TEST_DEVICES_5)
consentinformation.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)