Using iAd as default ad network, and AdMob if iAd fails

前端 未结 6 1381
既然无缘
既然无缘 2020-12-05 09:05

I\'ve built my app this way and everything seems to be working more or less. After hearing about the notoriously low iAd fill rate I decided that this would be the best meth

相关标签:
6条回答
  • 2020-12-05 09:14

    Are you hiding the ADBannerView by setting visible to NO? With the ADBannerView, if you set visible to NO, then it stops asking for ads. To "hide" the ADBannerView, you need to translate it to someplace off screen.

    0 讨论(0)
  • 2020-12-05 09:16

    I have iAds and Admob.

    I highly recommending loading an iAd first and if you dont get an Ad use admob. iAd has a much higher ECPM than admob if you get an ad. Remember that iAd refreshes every 30s so the did not get ad method will be called several times.

    My app has been approved you can get it, Octopus Oracle. http://kurl.ws/Ay

    0 讨论(0)
  • 2020-12-05 09:21

    You can use AdWhirl and its best tutorial is here Tutorial

    0 讨论(0)
  • 2020-12-05 09:28

    Why not use Adwhirl. Its great sdk that enables you to do exactly what you need. You can set priority settings for different ad networks which can be changed on the fly if you find one network performing better than others etc.

    It handles all the logic for which ad to show based on request failure or priority without you needing to worry about it. All you do is create an adwhirl view and request an ad. Adwhirl does the rest, including appropriate refreshing. If an iAd fails first time, and then shows an admob, but the next iAd loads successfully, it will be shown instead of the admob, assuming you set iAd as a higher priority network.

    http://adwhirl.com

    0 讨论(0)
  • 2020-12-05 09:29

    I ended up with this strategy:

    first of all I have created 2 outlets from the storyboard, one for the ADBannerView and another for the GADBannerView

    @IBOutlet weak var iadBannerView: ADBannerView!
    @IBOutlet weak var adMobBannerView: GADBannerView!
    

    In your viewDidLoad you can do this:

    override func viewDidLoad() {
        super.viewDidLoad()
        self.iadBannerView.hidden = true
        self.adMobBannerView.hidden = true
        self.iadBannerView.delegate = self
        NSTimer.scheduledTimerWithTimeInterval(35, target: self, selector: Selector("dispalyGoogleBanner"), userInfo: nil, repeats: false)
    }
    

    So here you hidden both banners (if you prefer you can do it directly in storyboard). then you wait 35 second before to display the google ads. So before to display the google ads you basically want to see if iAD it's available.

    this is the method used to display the google banner:

     //MARK: - Google banner
        func dispalyGoogleBanner() {
            if !self.isDisplayIAD && !idDisplayADMob {
            idDisplayADMob = true
            self.adMobBannerView.adUnitID = kAdUnitID
            self.adMobBannerView.hidden = false
            self.adMobBannerView.rootViewController = self
            self.adMobBannerView.loadRequest(GADRequest())
            }
        }
    

    so before to display the google banner, we ensure that the iAD banner and the adMob banner are not displayed yet. If that it's the case, then we can send the request to display the ADMob banner.

    Here my implementation of the ADBannerViewDelegate

    func bannerViewDidLoadAd(banner: ADBannerView!) {
            self.iadBannerView = banner
            self.iadBannerView.hidden = false
            self.adMobBannerView.hidden = true
            idDisplayADMob = false
            self.view.layoutIfNeeded()
        }
    
        func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError
            error: NSError!) {
                println(error)
                isDisplayIAD = false
                self.iadBannerView.hidden = true
                self.dispalyGoogleBanner()
        }
    
        func bannerViewActionDidFinish(banner: ADBannerView!) {
            self.iadBannerView = banner
            self.iadBannerView.hidden = true
            isDisplayIAD = false
            dispalyGoogleBanner()
        }
    
        func bannerViewWillLoadAd(banner: ADBannerView!) {
            //remove the google banner if displayed
            isDisplayIAD = true
            self.iadBannerView.hidden = false
            self.adMobBannerView.hidden = true
            idDisplayADMob = false
            self.view.layoutIfNeeded()
        }
    

    what I basically did on these delegates it's to check if the iAD banner it's available, if that it's case then I'll hidden the adMob banner. If the iAD finished to display the ads, then I'll call the ADMob banner see bannerViewActionDidFinish

    You can easily adapt this logic tu your implementation.

    0 讨论(0)
  • 2020-12-05 09:30

    You can use these controls to show iAds as well as adMob both

    iAdPlusAdMob

    CJPAdController

    Or here is nice tut that explain step by step

    http://mobile.tutsplus.com/tutorials/iphone/supplementing-iad-placement-with-admob/

    0 讨论(0)
提交回复
热议问题