Don’t want to show ads on YouTube pages.

After buy from CodeCnyon, Everything was working fine. But as you know showing ads on the youtube video is violate policy. So how can I ignore ads on YouTube pages?

Solution 1: If your app opens the link on YouTube then do not open the YouTube website inside of your app. Open the YouTube website outside of the app or open in custom TAB.
Follow this to open external browser: https://help.infixsoft.com/how-to-open-a-link-outside-the-app/
Follow this to open custom TAB: https://help.infixsoft.com/how-to-open-external-url-on-custom-tab/

Solution 2: Some time we have YouTube videos play inside of the website using a plugin. In this case, it’s better not to use AdMob because it violates the policy. If you want to open youtube video inside the app then follow:

if(url.contains("youtube")){
    layout_footer.visibility = View.GONE
    view_admob.visibility = View.GONE
}else{
    layout_footer.visibility = View.VISIBLE
    view_admob.visibility = View.VISIBLE
}

Tips 1: In case you don’t want to set ads on any specific subdomain or your youtube video is embedded inside the website then the code will be.

And must need to set the exact same URL that’s the load on the page.

if(url =="https://help.infixsoft.com/"){
    layout_footer.visibility = View.GONE
    view_admob.visibility = View.GONE
}else{
    layout_footer.visibility = View.VISIBLE
    view_admob.visibility = View.VISIBLE
}

Then set your URL here:

override fun onAdLoaded() {
runOnUiThread {
if(mSuccessLoadedUrl != "https://help.infixsoft.com") {
view_banner_ads.visibility = View.VISIBLE
if (layout_footer.visibility == View.GONE) {
layout_footer.visibility = View.VISIBLE
val slideUp: Animation = AnimationUtils.loadAnimation(mContext, R.anim.anim_slide_up)
layout_footer.startAnimation(slideUp)
}
}
}
}

Tips 2: In case you want to be set for multiple pages then code will look like:

if(url == "https://help.infixsoft.com" 
    && url == "https://help.infixsoft.com/xxx" 
    && url == "https://help.infixsoft.com/xxx?yyy=000")

if(mSuccessLoadedUrl != "https://help.infixsoft.com" 
   && mSuccessLoadedUrl != "https://help.infixsoft.com/xxx" 
   && SuccessLoadedUrl != "https://help.infixsoft.com/xxx?yyy=000")

Leave a Reply