Reputation: 194
I have some problem with Native Ads. I getting empy list of Native Ads. Here is code:
Appodeal.setAutoCacheNativeIcons(true)
Appodeal.setAutoCacheNativeMedia(false)
Appodeal.initialize(this, apiKey, Appodeal.NATIVE)
Appodeal.setNativeCallbacks(object : NativeCallbacks {
override fun onNativeLoaded() {
Toast.makeText(this@ViewActivity, "onNativeLoaded", Toast.LENGTH_SHORT).show()
}
override fun onNativeFailedToLoad() {
Toast.makeText(this@ViewActivity, "onNativeFailedToLoad", Toast.LENGTH_SHORT).show()
}
override fun onNativeShown(nativeAd: NativeAd) {
Toast.makeText(this@ViewActivity, "onNativeShown", Toast.LENGTH_SHORT).show()
}
override fun onNativeClicked(nativeAd: NativeAd) {
Toast.makeText(this@ViewActivity, "onNativeClicked", Toast.LENGTH_SHORT).show()
}
})
val list = Appodeal.getNativeAds(5)
nativeAd.getProviderView(this)
Toast.makeText(this@ViewActivity, "size = " + list.size , Toast.LENGTH_SHORT).show()
So every time I got list.size equals 0. What i did wrong?
Upvotes: 1
Views: 1120
Reputation: 61
Disable autocache
before initialization of sdk
using Appodeal.setAutoCache(Appodeal.NATIVE, false);
method.
After it, need to use cache method Appodeal.cache(this, Appodeal.NATIVE, 5);
after initialization of sdk
simple example:
Appodeal.setAutoCache(Appodeal.NATIVE, false);
Appodeal.initialize(this, tools.appodealApiKey, Appodeal.NATIVE)
Appodeal.cache(this, Appodeal.NATIVE, 5);
and move Appodeal.getNativeAds(5);
and etc. to onNativeLoaded()
callback.
After showing cached ads, need to use cache method again
Upvotes: 2