gpt4 book ai didi

ios - 应用已获批准但未显示 AdMob 广告

转载 作者:可可西里 更新时间:2023-11-01 05:43:51 31 4
gpt4 key购买 nike

由于 Apple 在审核过程中没有发现我的广告,我的 iOS 申请被拒绝了。我再次上​​传了我的申请,包括如何查看广告的说明,今天获得批准。现在,一旦我的 friend 和家人下载了该应用程序,就不会出现任何广告。我检查了我的 AdMob 帐户,但没有显示任何展示次数,所以我不知道出了什么问题。有没有人遇到过这种情况?此外,应用程序获得批准还不到 24 小时。由于 Apple 批准了它,我认为他们已经看到了广告。 My application当您选择一张照片后开始使用过滤器时显示广告。 AdMob 显示 61 次展示、61 次请求和 100% 填充率。

// Initialize Apple iAd banner
func initiAdBanner() {
iAdBannerView = ADBannerView(frame: CGRectMake(0, self.view.frame.size.height, 0, 0) )
iAdBannerView.delegate = self
iAdBannerView.hidden = true
view.addSubview(iAdBannerView)
}

// Initialize Google AdMob banner
func initAdMobBanner() {
if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad {
// iPad banner
adMobBannerView.adSize = GADAdSizeFromCGSize(CGSizeMake(728, 90))
adMobBannerView.frame = CGRectMake(0, self.view.frame.size.height, 728, 90)
} else {
// iPhone banner
adMobBannerView.adSize = GADAdSizeFromCGSize(CGSizeMake(320, 50))
adMobBannerView.frame = CGRectMake(0, self.view.frame.size.height, 320, 50)
}
adMobBannerView.adUnitID = "AdMobPublisherID"
adMobBannerView.rootViewController = self
adMobBannerView.delegate = self
// adMobBannerView.hidden = true
view.addSubview(adMobBannerView)
var request = GADRequest()
adMobBannerView.loadRequest(request)
}

// Hide the banner
func hideBanner(banner: UIView) {
if banner.hidden == false {
UIView.beginAnimations("hideBanner", context: nil)
// Hide the banner moving it below the bottom of the screen
banner.frame = CGRectMake(0, self.view.frame.size.height, banner.frame.size.width, banner.frame.size.height)
UIView.commitAnimations()
banner.hidden = true
}
}

// Show the banner
func showBanner(banner: UIView) {
if banner.hidden == true {
UIView.beginAnimations("showBanner", context: nil)
// Move the banner on the bottom of the screen
banner.frame = CGRectMake(0, (self.view.frame.size.height-70) - banner.frame.size.height,
banner.frame.size.width, banner.frame.size.height);
UIView.commitAnimations()
banner.hidden = false
}
}

// iAd banner available
func bannerViewWillLoadAd(banner: ADBannerView!) {
println("iAd loaded!")
hideBanner(adMobBannerView)
showBanner(iAdBannerView)
}

// NO iAd banner available
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
println("iAd can't looad ads right now, they'll be available later")
hideBanner(iAdBannerView)
var request = GADRequest()
adMobBannerView.loadRequest(request)
}

// AdMob banner available
func adViewDidReceiveAd(view: GADBannerView!) {
println("AdMob loaded!")
hideBanner(iAdBannerView)
showBanner(adMobBannerView)
}

// NO AdMob banner available
func adView(view: GADBannerView!, didFailToReceiveAdWithError error: GADRequestError!) {
println("AdMob Can't load ads right now, they'll be available later \n\(error)")
hideBanner(adMobBannerView)
}

最佳答案

广告现在出现在您的应用程序中。当您的申请获得 Apple 批准后,您还必须获得 iAd 团队的批准才能接收 iAd 广告。这可能还需要几天时间。因此,您的两个广告都没有显示在您的应用程序中。您可以通过转到“设置”>“开发人员”> 并将您的开发设备上的填充率设置为 0% 来对此进行测试。如果 iAd 最初未能加载,则两个广告都不会显示的原因是因为此功能:

    // Show the banner
func showBanner(banner: UIView) {
if banner.hidden == true {
UIView.beginAnimations("showBanner", context: nil)

// Move the banner on the bottom of the screen
banner.frame = CGRectMake(0, (self.view.frame.size.height-70) - banner.frame.size.height,
banner.frame.size.width, banner.frame.size.height);

UIView.commitAnimations()
banner.hidden = false
}
}

您正在检查 if banner.hidden == true 但您的 adMobBannerViewhidden 值从未设置为 true 直到加载 iAd 横幅。由于在 iAd 团队批准之前没有加载 iAd 横幅,因此从未满足此条件。在不支持 iAd 或 iAd 最初无法加载广告的国家/地区,也永远不会满足此条件。

此外,由于您在屏幕上和屏幕外设置了动画,因此加载广告时会跳跃。一种更优雅的方法是为它们的 alpha 值设置动画,这样用户就不会注意到您的广告何时发生变化。您还可以消除很多代码。我已经重写了您想要完成的内容,并注释掉了其背后的原因。

import UIKit
import iAd

class ViewController: UIViewController, ADBannerViewDelegate, GADBannerViewDelegate {

var iAdBannerView : ADBannerView = ADBannerView()
var adMobBannerView : GADBannerView = GADBannerView()

override func viewDidLoad() {
super.viewDidLoad()
loadAds()
}

func loadAds() {
// iAd
// Changed banners width to match the width of the view it is on
// You need to set the y origin relative to your view. Not a static number.
iAdBannerView = ADBannerView(frame: CGRectMake(0, self.view.frame.size.height - iAdBannerView.frame.height, self.view.frame.size.width, iAdBannerView.frame.height))
iAdBannerView.delegate = self
view.addSubview(iAdBannerView)
// Hide iAd initially
iAdBannerView.alpha = 0.0

// AdMob
// Changed adSize to Googles set banner size
adMobBannerView.adSize = kGADAdSizeBanner
// Changed banners width to match the width of the view it is on
// You need to set the y origin relative to your view. Not a static number.
adMobBannerView.frame = CGRectMake(0, self.view.frame.size.height - adMobBannerView.frame.height , self.view.frame.size.width, adMobBannerView.frame.height)
adMobBannerView.rootViewController = self
adMobBannerView.delegate = self
adMobBannerView.adUnitID = "AdMobPublisherID"
// Dont need var request = GADRequest()
adMobBannerView.loadRequest(GADRequest())
// Do not hide AdMob initially
view.addSubview(adMobBannerView)
}

// Use bannerViewDidLoadAd function so we know ad is fully loaded
func bannerViewDidLoadAd(banner: ADBannerView!) {
println("iAd has an ad to show")
// Animate fade of banners
UIView.beginAnimations(nil, context: nil)
// Show iAd
iAdBannerView.alpha = 1.0
// Hide AdMob
adMobBannerView.alpha = 0.0
UIView.commitAnimations()
}

func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {
println("iAd failed to load an ad because \(error)")
// Animate fade of banners
UIView.beginAnimations(nil, context: nil)
// Hide iAd
iAdBannerView.alpha = 0.0
// Show AdMob
adMobBannerView.alpha = 1.0
UIView.commitAnimations()
}

这有利于 iAd,如果 iAd 无法加载广告,则回退到 AdMob。您无需检查 AdMob 何时无法加载广告,因为它的填充率几乎总是 100%,如果没有 AdMob 广告,我怀疑是否有 iAd 广告可以展示。

关于ios - 应用已获批准但未显示 AdMob 广告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30386514/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com