インタースティシャル広告はフルスクリーンで表示され、一般的にはバナー広告よりも高いレベルの双方向性を提供するリッチメディアを埋め込みます。 インタースティシャルは通常、アプリケーションの起動中やゲームでのステージ作成中、コンテンツのダウンロード中といったような待ち画面の間に表示されます。 あなたは (*MPInterstitialAdController*) とそのデリゲートコールバックを使い、インタースティシャル広告を読み込んでアプリに表示することができます。
Integrating Interstitial AdsInterstitial ads provide full-screen experiences, commonly incorporating rich media to offer a higher level of interactivity than banner ads. Interstitials are typically shown during natural transitions in your application, such as on app launch, after completing a game level, or while your app is downloading content from the internet. You can use the (*MPInterstitialAdController*) and its delegate callbacks to fetch and display interstitial ads in your app. |
インタースティシャル広告をアプリに組み込む前に、入門ガイドの手順を踏んでMoPub のアカウントを作成し、プロジェクトにSDK を組み込む必要があります。
Prerequisites:Before integrating interstitial ads in your app, you’ll need to go through the steps in our Getting Started Guide to create an account on MoPub and integrate the SDK into your project. |
重要: MRC を使用している場合はこれらのファイルに `-fobjc-arc` のコンパイラフラグを設定する必要があります。 ここに記載された説明に従ってください。
// MyViewController.h #import "MPInterstitialAdController.h" //If using the open source SDK #import <MoPub/MoPub.h> //If integrating using Fabric @interface MyViewController : UIViewController @property (nonatomic) MPInterstitialAdController *interstitial; @end
// MyViewController.m #import "MyViewController.h" @implementation MyViewController // Our loadView implementation will pre-fetch our interstitial ad. - (void)loadView { // ... your other -loadView code ... [self loadInterstitial]; } - (void)loadInterstitial { // Instantiate the interstitial using the class convenience method. self.interstitial = [MPInterstitialAdController interstitialAdControllerForAdUnitId:@"<YOUR_ADUNIT_ID_HERE>"]; // Fetch the interstitial ad. [self.interstitial loadAd]; } // Present the ad only after it is ready. - (void)levelDidEnd { if (self.interstitial.ready) [self.interstitial showFromViewController:self]; else { // The interstitial wasn't ready, so continue as usual. } }
Basic integration
IMPORTANT: If you are using MRC you’ll need to set the `-fobjc-arc` compiler flag on these files. Follow the instructions here. // MyViewController.h #import "MPInterstitialAdController.h" //If using the open source SDK #import <MoPub/MoPub.h> //If integrating using Fabric @interface MyViewController : UIViewController @property (nonatomic) MPInterstitialAdController *interstitial; @end // MyViewController.m #import "MyViewController.h" @implementation MyViewController // Our loadView implementation will pre-fetch our interstitial ad. - (void)loadView { // ... your other -loadView code ... [self loadInterstitial]; } - (void)loadInterstitial { // Instantiate the interstitial using the class convenience method. self.interstitial = [MPInterstitialAdController interstitialAdControllerForAdUnitId:@"<YOUR_ADUNIT_ID_HERE>"]; // Fetch the interstitial ad. [self.interstitial loadAd]; } // Present the ad only after it is ready. - (void)levelDidEnd { if (self.interstitial.ready) [self.interstitial showFromViewController:self]; else { // The interstitial wasn't ready, so continue as usual. } } |
*MPInterstitialAdControllerDelegate*にはイベントを通知するのに使用できる様々なオプションコールバックが含まれています。 例えば、インタースティシャルの読み込みに成功した場合や、インタースティシャルが表示されようとする時などに発生するイベントです。 これらメソッドの一覧については、MPInterstitialAdController.h 内のMPInterstitialAdControllerDelegate を参照してください。
サンプル1(事前読み込み):`-interstitialDidLoadAd:`を実装して、インタースティシャルの読み込みが成功したことを通知させることができます。
サンプル2(Presentation/dismissal callbacks): あなたのアプリケーションがゲームで、インタースティシャル広告が表示されている時はゲームを一時停止させ、 広告が消された時にゲームを再開したいとします。オプションの`-interstitialWillAppear:` と `-interstitialDidDisappear` デリゲートコールバックを使用してこれを実現できます。:
- (void)interstitialWillAppear:(MPInterstitialAdController *)interstitial { [self pauseGame]; } - (void)interstitialDidDisappear:(MPInterstitialAdController *)interstitial { [self resumeGame]; }
Receiving optional delegate callbacks*MPInterstitialAdControllerDelegate* includes a variety of optional callbacks tthat you can use to be notified of events, e.g. when an interstitial has successfully loaded, or when an interstitial is about to appear. Check out the MPInterstitialAdControllerDelegate in MPInterstitialAdController.h for a list of these methods. Example 1(Pre-fetching):*You can be notified that an interstitial was fetched successfully by implementing `-interstitialDidLoadAd:`. Example 2(Presentation/dismissal callbacks): Suppose that your application is a game. You’d like to pause the game whenever you present an interstitial, and resume it when the interstitial is dismissed. You can accomplish this using the optional `-interstitialWillAppear:` and `-interstitialDidDisappear` delegate callbacks: - (void)interstitialWillAppear:(MPInterstitialAdController *)interstitial { [self pauseGame]; } - (void)interstitialDidDisappear:(MPInterstitialAdController *)interstitial { [self resumeGame]; } |