2013-12-23 62 views
16

我的開發人員和我以前曾試圖在iPhone和iPad上加載插頁式廣告,但只能在iPad上使用此功能。iPhone上的iAds插頁式廣告?

在我們的測試中,我們發現iPhone上不支持插頁式廣告,但自iOS7發佈以來,有些人現在認爲這是可行的。

但是我找不到任何像樣的文檔。這個Stack問題讓我想起了iAd & Admob Interstitial Integration on iPhone

那麼,iPhone上使用iAds的全屏插頁式廣告可能嗎?

+0

他們不支持iAds,但還有很多其他網絡,如Admob,Amazon和Chartboost。看看http://appodeal.com/+signup。在android上使用它,他們平均支付7-9美元的有效每千次展示費用,並支持插頁式和插頁式視頻! –

回答

20

我也一直在等待來自iAd的iPhone插頁式廣告。我終於將它實現到我的一個應用程序中,並且正在運行並顯示測試廣告。該應用目前正在審覈中,我將在獲得批准後更新我的答案,並且可以測試是否投放了任何實際的廣告。在此期間,這裏是我用來實現iAd的插頁廣告代碼:

ViewController.h

@interface ViewController : UIViewController <ADInterstitialAdDelegate> { 
    ADInterstitialAd *interstitial; 
    BOOL requestingAd; 
} 

-(void)showFullScreenAd; 

ViewController.m

-(void)viewDidLoad { 
    requestingAd = NO; 
} 

// Interstitial iAd 
-(void)showFullScreenAd { 
    // Check if already requesting ad 
    if (requestingAd == NO) { 
     [ADInterstitialAd release]; 
     interstitial = [[ADInterstitialAd alloc] init]; 
     interstitial.delegate = self; 
     self.interstitialPresentationPolicy = ADInterstitialPresentationPolicyManual; 
     [self requestInterstitialAdPresentation]; 
     NSLog(@"interstitialAdREQUEST"); 
     requestingAd = YES; 
    } 
} 

-(void)interstitialAd:(ADInterstitialAd *)interstitialAd didFailWithError:(NSError *)error { 
    interstitial = nil; 
    [interstitialAd release]; 
    [ADInterstitialAd release]; 
    requestingAd = NO; 
    NSLog(@"interstitialAd didFailWithERROR"); 
    NSLog(@"%@", error); 
} 

-(void)interstitialAdDidLoad:(ADInterstitialAd *)interstitialAd { 
    NSLog(@"interstitialAdDidLOAD"); 
    if (interstitialAd != nil && interstitial != nil && requestingAd == YES) { 
     [interstitial presentFromViewController:self]; 
     NSLog(@"interstitialAdDidPRESENT"); 
    } 
} 

-(void)interstitialAdDidUnload:(ADInterstitialAd *)interstitialAd { 
    interstitial = nil; 
    [interstitialAd release]; 
    [ADInterstitialAd release]; 
    requestingAd = NO; 
    NSLog(@"interstitialAdDidUNLOAD"); 
} 

-(void)interstitialAdActionDidFinish:(ADInterstitialAd *)interstitialAd { 
    interstitial = nil; 
    [interstitialAd release]; 
    [ADInterstitialAd release]; 
    requestingAd = NO; 
    NSLog(@"interstitialAdDidFINISH"); 
} 

我只是叫-(void)showFullScreenAd用戶後執行某個動作。欲瞭解更多信息,請參閱UIViewController iAd Additions Reference

編輯:01/03/14 該應用程序更新已獲批准,並且已經生效了12個小時。截至目前,我還沒有收到任何插頁式廣告。這可能是由於缺乏iPhone上的插頁式廣告的廣告資源,或者與我在iTunes Connect上的iAd模塊中收到的以下消息有關。賀電

When you submit your app, [app name], for approval, it will also be reviewed by iAd for use on the App Network to determine its appropriateness for receiving ads from iAd advertisers. Once your app is approved, you will be ready to start earning revenue for ads that run in your app.

我以前從來沒有收到這個消息時,我通常會收到「您的應用程序現在有資格接收廣告」儘快更新在App Store發佈的消息。這要麼是因爲我的應用中插播式廣告的新實施,要麼是Apple更新了一些iAd程序。

如果當我開始接收插頁式廣告時,會再次更新答案。與此同時,您可以在我的應用程序+Quotes上自行測試。上述代碼被調用,並且一旦用戶通過Facebook在應用內分享,插頁式廣告應該會顯示。

編輯:14年1月7日 聯繫了iAd的直接和接收響應今天

Hello Daniel, Initial fill rates will reflect the recent launch of interstitials on iOS 7. Thank you for your patience as we ramp up ad serving. If you haven't already, we recommend you integrate standard portrait and landscape iAd banners in your app to take advantage of all available types of advertising inventory. Finally, for future reference, when you submit your app for approval, it will also be reviewed by iAd to determine its appropriateness for receiving ads from iAd advertisers. Therefore, it may take a few days for your new iAd enabled app to begin receiving ad impressions. Best Regards,  iAd App Network Support

因此,對於iPhone間質性成癮者都裝有iOS 7.0及以上的工作,但具有低填充率目前。

+0

代碼僅適用於iOS7嗎?期待在您的應用上線後看到您的更新。 – pixelkicks

+0

@Buckers是的,新的iAd新增功能需要iOS 7.0或以上版本[UIViewController iAd Additions Reference](https://developer.apple.com/library/ios/documentation/iAd/Reference/UIViewController_iAd_Additions/Reference/Reference.html #// apple_ref/occ/instm/UIViewController/requestInterstitialAdPresentation) –

+2

@DanielStormApps這個功能差不多,只是'[interstitial presentFromViewController:self];'從iOS7開始已被棄用。使用'[interstitial presentInView:self.view];'而不是 – zero3nna

2

我原來的答覆是開始遠離年齡所以這裏是一個較新的雨燕實現:

這個實現使用ManualADInterstitialPresentationPolicy,所以我們可以在我們自己的時間間隔提出我們的插頁式廣告。手動呈現插頁式廣告時,它不會使用自己的關閉按鈕加載自己。因此,我所做的是創建了一個UIView來呈現插頁式廣告,並使用插頁式廣告的委託方法來解除UIView。測試時仍會出現與從iAd網絡接收廣告不一致的情況。有時候您會收到一則廣告,有時無法加載,這使得我們可能會要求發佈新廣告,有時甚至沒有任何反應。這似乎是iAd插頁式廣告的本質。

import UIKit 
import iAd // Import iAd 

class ViewController: UIViewController, ADInterstitialAdDelegate { // Include the delegate 

    var iAdInterstitial = ADInterstitialAd() // Our ad 
    var iAdInterstitialView = UIView() // View to present our ad in 
    var adLoaded = false // Bool to keep track if an ad is loaded or not 

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

    func setupAd() { 
     // Set presentation to manual so we can choose when to present the interstitial 
     // Setting this will also fetch an interstitial ad for us 
     self.interstitialPresentationPolicy = ADInterstitialPresentationPolicy.Manual 
     iAdInterstitial.delegate = self // Set the delegate 

     // Make our view the same size as the view we will be presenting in 
     iAdInterstitialView.frame = self.view.bounds 
    } 

    func requestNewAd() { 
     // This will fetch an ad for us 
     ViewController.prepareInterstitialAds() 
     println("Requesting new ad") 
    } 

    @IBAction func presentAdButton(sender: AnyObject) { 
     if (adLoaded) { 
      // We have an ad that is loaded so lets present it 
      self.view.addSubview(iAdInterstitialView) 
      iAdInterstitial.presentInView(iAdInterstitialView) 
     } 
     else { 
      // No ad has been loaded 
      println("Ad not loaded") 
     } 
    } 

    func interstitialAdDidUnload(interstitialAd: ADInterstitialAd!) { 
     // Kinda works as expected 
     // Sometimes is called prematurely 
     // Sometimes takes minutes after ad is dismissed to be called 
     println("interstitialAdDidUnload") 

     // Get new ad 
     adLoaded = false 
     iAdInterstitialView.removeFromSuperview() 
     requestNewAd() 
    } 

    func interstitialAd(interstitialAd: ADInterstitialAd!, didFailWithError error: NSError!) { 
     // Failed to load ad so lets try again 
     println("didFailWithError: \(error)") 
     requestNewAd() 
    } 

    func interstitialAdWillLoad(interstitialAd: ADInterstitialAd!) { 
     // There is an ad and it has begun to download 
     println("interstitialAdWillLoad") 
    } 

    func interstitialAdDidLoad(interstitialAd: ADInterstitialAd!) { 
     // We got an ad 
     println("interstitialAdDidLoad") 
     adLoaded = true 
    } 

    func interstitialAdActionShouldBegin(interstitialAd: ADInterstitialAd!, willLeaveApplication willLeave: Bool) -> Bool { 
     println("interstitialAdActionShouldBegin") 
     return true; 
    } 

    func interstitialAdActionDidFinish(interstitialAd: ADInterstitialAd!) { 
     // Done with this ad. Lets get a new one 
     println("interstitialAdActionDidFinish") 
     iAdInterstitialView.removeFromSuperview() 
     adLoaded = false 
     requestNewAd() 
    } 
+1

這很好,謝謝 – Pete

+0

我使用上面的代碼,但總是得到錯誤消息didFailWithError:Error Domain = ADErrorDomain Code = 3「操作無法完成。廣告資源不可用」的UserInfo = {0x7fe5584be760 = ADInternalErrorCode 3,NSLocalizedFailureReason =廣告資源不可用,ADInternalErrorDomain = ADErrorDomain} 請求沒有加載新的廣告 廣告--------啓用設置// //開發商填充率始終100% –