我创建了一个按钮来在点击时显示奖励广告。现在有两个问题: 1. 加载广告花费了太多时间(我可以在任何事情发生之前单击按钮一次或两次)。2. 我想在广告关闭后立即重新加载广告。它可以工作,但应用程序需要重新启动。
AdMobRewardedComponent.js
async componentDidMount() {
await setTestDeviceIDAsync("EMULATOR");
AdMobRewarded.setAdUnitID("ca-app-pub-3940256099942544/5224354917");
AdMobRewarded.addEventListener("rewardedVideoDidLoad", () => {
console.log("VideoLoaded")
});
AdMobRewarded.addEventListener("rewardedVideoDidFailToLoad", () =>
console.log("FailedToLoad")
);
AdMobRewarded.addEventListener("rewardedVideoDidOpen", () =>
console.log("Opened")
);
AdMobRewarded.addEventListener("rewardedVideoDidClose", () => {
loadAd(request.build());
console.log("Closed")
});
AdMobRewarded.addEventListener("rewardedVideoWillLeaveApplication", () =>
console.log("LeaveApp")
);
AdMobRewarded.addEventListener("rewardedVideoDidStart", () =>
console.log("Started")
);
AdMobRewarded.addEventListener("rewardedVideoDidRewardUser", () =>
console.log("Rewarded"),
);
await AdMobRewarded.requestAdAsync();
}
componentWillUnmount() {
AdMobRewarded.removeAllListeners();
}
_handlePress = async () => {
await AdMobRewarded.showAdAsync();
};
render() {
const { loadedAd } = this.state;
return (
<TouchableButton onPress={this._handlePress} title="Coins erhalten!" image="adButton" status="active" style={styles.adButton}/>
);
}
};
有没有办法在不重新启动整个应用程序的情况下请求新广告?感谢您的每一个回答!