1

I have implemented reward ad in my code , so basically when the user is done doing a task , will get rewarded , now the issue is that with the old version of google ads using reward ad , there was function called onRewardAdClose() but when i tried to call it in the newest version , it dosnt exit , i have checked the documentation but that function is not mentioned , did it any implement the latest version to guide me solve this issue thank you in advance , this is my code ..

  • Show Ad onClickListener

 binding.addJob.setOnClickListener {
            createRewardAd()
        }

  • Code to show ad
val adRequest = AdRequest.Builder().build()

        RewardedAd.load(requireContext(),"ca-app-pub-3940256099942544/5224354917", adRequest, object : RewardedAdLoadCallback() {
            override fun onAdFailedToLoad(adError: LoadAdError) {
                rewardedAd = null
                Log.d("TAG","Exception ${adError.message}")
            }

            override fun onAdLoaded(rewardedAd2: RewardedAd) {
                rewardedAd = rewardedAd2

                rewardedAd?.fullScreenContentCallback = object: FullScreenContentCallback() {
                    override fun onAdShowedFullScreenContent() {
                    }

                    override fun onAdFailedToShowFullScreenContent(adError: AdError?) {
                        Log.d("TAG","Exception ${adError?.message}")
                    }

                    override fun onAdDismissedFullScreenContent() {
                        rewardedAd = null
                    }
                }

            }
        })

        if (rewardedAd != null) {
            rewardedAd?.show(requireActivity(),object : OnUserEarnedRewardListener{
                override fun onUserEarnedReward(item: RewardItem) {
                      // reward the user
                }
            })
        } else {
            Log.d("TAG", "The rewarded ad wasn't ready yet.")

        }

Taki
  • 3,290
  • 1
  • 16
  • 41

0 Answers0