AdMobBanner 的 `testDeviceID` 道具已弃用。测试设备 ID 现在全局设置。使用 AdMob.setTestDeviceIDAsync 代替
The `testDeviceID` prop of AdMobBanner is deprecated. Test device IDs are now set globally. Use AdMob.setTestDeviceIDAsync instead
我最近一直在制作一个基于真实本机的应用程序。我还使用 Google 的 admob 放了一个广告横幅 直到几天前才出现的广告。
设置下面的 admob 属性会导致错误。
<AdMobBanner
bannerSize="banner"
adUnitID="ca-app-pub-@@@@@@@"
testDeviceID="EMULATOR"
servePersonalizedAds = {true}
onDidFailToReceiveAdWithError={this.bannerError}
/>
报错如下
The `testDeviceID` prop of AdMobBanner is deprecated. Test device IDs are now set globally. Use AdMob.setTestDeviceIDAsync instead.
如果你能帮助我,我将不胜感激。
我遇到了同样的问题,他们应该更新世博会网站上的信息。我相信这也适用于横幅。
导入:
import {
setTestDeviceIDAsync, //<--- I forgot this first time
AdMobInterstitial
}from 'expo-ads-admob';
挂载后初始化:
componentDidMount(){
this.initAds().catch((error) => console.log(error));
}
initAds = async () => {
AdMobInterstitial.setAdUnitID('ca-app-pub-3940256099942544/1033173712') //test id
await setTestDeviceIDAsync('EMULATOR');
}
通过按钮或任何您喜欢的方式触发此功能:
_openInterstitial = async () => {
try {
this.setState({ disableInterstitialBtn: true })
await AdMobInterstitial.requestAdAsync()
await AdMobInterstitial.showAdAsync()
} catch (error) {
console.error(error)
} finally {
this.setState({ disableInterstitialBtn: false })
}
}
我最近一直在制作一个基于真实本机的应用程序。我还使用 Google 的 admob 放了一个广告横幅 直到几天前才出现的广告。 设置下面的 admob 属性会导致错误。
<AdMobBanner
bannerSize="banner"
adUnitID="ca-app-pub-@@@@@@@"
testDeviceID="EMULATOR"
servePersonalizedAds = {true}
onDidFailToReceiveAdWithError={this.bannerError}
/>
报错如下
The `testDeviceID` prop of AdMobBanner is deprecated. Test device IDs are now set globally. Use AdMob.setTestDeviceIDAsync instead.
如果你能帮助我,我将不胜感激。
我遇到了同样的问题,他们应该更新世博会网站上的信息。我相信这也适用于横幅。
导入:
import {
setTestDeviceIDAsync, //<--- I forgot this first time
AdMobInterstitial
}from 'expo-ads-admob';
挂载后初始化:
componentDidMount(){
this.initAds().catch((error) => console.log(error));
}
initAds = async () => {
AdMobInterstitial.setAdUnitID('ca-app-pub-3940256099942544/1033173712') //test id
await setTestDeviceIDAsync('EMULATOR');
}
通过按钮或任何您喜欢的方式触发此功能:
_openInterstitial = async () => {
try {
this.setState({ disableInterstitialBtn: true })
await AdMobInterstitial.requestAdAsync()
await AdMobInterstitial.showAdAsync()
} catch (error) {
console.error(error)
} finally {
this.setState({ disableInterstitialBtn: false })
}
}