AdMob ads open from website button click

After buying from CodeCanyon I set it up completely and everything was working fine now I want to open ads from my website.

When you click the button an URL will generate a URL. So you can connect the URL with RocketWeb ads.
For example, when I click on the website it will generate this URL (“https://help.infixsoft.com/show_rewarded_ad”). Remember you need to set exactly the URL that is loading.

First, replace this line of code to remove the initial timer:

mRewardedVideoAd = null
initRewardedAdMob(rewardedAdID)

Then Update here:

Then Update here:

After that remove this line of code:

Now my button click URL is https://help.infixsoft.com/show_rewarded_ad so in my case code will be like this. And you need to set the same code on both the below method.

 if (url == "https://help.infixsoft.com/show_rewarded_ad") {
            if (isApplicationAlive && mRewardedVideoAd != null) {
                mRewardedVideoAd?.show(this@HomeActivity) {
                    fun onUserEarnedReward(rewardItem: RewardItem) {
                        val rewardAmount = rewardItem.amount
                        val rewardType = rewardItem.type
                        Log.d(TAG, "Reward type: $rewardType")
                        Log.d(TAG, "Reward amount: $rewardAmount")
                    }
                }
                return true
            }
        }

Notice please set exactly the full URL that’s generated on your browser when your click. And if you want to add more URLs then you can repeat this line of code.

2 thoughts on “AdMob ads open from website button click

Leave a Reply