I am implementing the Vungle ads in my android app,
the problem is when the user closes the app by swiping up the app after pressing the overview button (the right one from default buttons), meanwhile, Vungle rewarded ad was running,
After closing the application while the rewarded ad is running Vungle ad behavior is weird,
when the user open the app again it never shows the new ad, even ad is available (canPlayAd returns true) but ad could not be played, or sometimes rewarded call back runs, even app is closed by the user.
I just want to destroy/close the Vungle rewarded ad, when the application's main activity's onDestroy called. Thanks
if (Vungle.canPlayAd(placementId)) {
editActivityUtils.logGeneralEvent(context, "rewardedVdoPlayed", "$cat_name: $name")
firebaseAnalytics.setUserProperty("rewardedVdoPlayed", "$cat_name")
Vungle.playAd(placementId, adConfig, object : PlayAdCallback {
override fun onAdStart(id: String) {}
override fun onAdEnd(id: String, completed: Boolean, isCTAClicked: Boolean) {
Log.e("app", "Vungle ad end")
if ((!(context as TemplatesMainActivity).isDestroyed) && completed) {
Vungle.loadAd(placementId, object : LoadAdCallback {
override fun onAdLoad(id: String?) {
}
override fun onError(id: String?, exception: VungleException?) {
}
})
Log.e("app", "Vungle ad rewarded")
editActivityUtils.logGeneralEvent(context, "gotTemplateByRewardedVdo", "$cat_name: $name")
firebaseAnalytics.setUserProperty("gotTemplateByRewardedVdo", "$cat_name")
goToEditorWithoutAD(cat_name, name)
}
}
override fun onAdEnd(id: String) {}
override fun onAdClick(id: String) {}
override fun onAdRewarded(id: String) {
Log.e("app", "Vungle ad rewarded")
}
override fun onAdLeftApplication(id: String) {
Log.e("app", "Vungle left app")
}
override fun onError(id: String, exception: VungleException) {
Log.e("app", "Vungle ${exception.localizedMessage}")
}
})
}