Created
December 15, 2012 01:27
-
-
Save pjlaird/4290326 to your computer and use it in GitHub Desktop.
Integrate Tap for Tap into MoPub on iOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <Foundation/Foundation.h> | |
| #import "MPAdView.h" | |
| #import "TapForTap.h" | |
| @interface MyViewController : UIViewController <MPAdViewDelegate, TapForTapAdViewDelegate> | |
| @end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import "MyViewController.h" | |
| @interface MyViewController.h () | |
| @property (strong, nonatomic) MPAdView *adView; | |
| @end | |
| @implementation MyViewController.h | |
| @synthesize adView = _adView; | |
| - (void)viewDidLoad | |
| { | |
| [super viewDidLoad]; | |
| [TapForTap initializeWithAPIKey: @"YOUR API KEY"]; | |
| *adView = [[MPAdView alloc] initWithAdUnitId:@"AD UNITY ID" size:MOPUB_BANNER_SIZE]; | |
| adView.delegate = self; | |
| [adView loadAd]; | |
| [self.view addSubview:adView]; | |
| [adView release];} | |
| <#methods#> | |
| - (void)tapForTapCustomEvent:(MPAdView *)theAdView | |
| { | |
| TapForTapAdView *adView = [[TapForTapAdView alloc] initWithFrame: CGRectMake(0, 0, 320, 50) delegate: self]; | |
| self.adView.autoRollover = NO; | |
| } | |
| - (void) tapForTapAdViewDidReceiveAd: (TapForTapAdView *)adView | |
| { | |
| // Signal to our MPAdView that the custom event successfully loaded an AdMob ad. | |
| [self.mpAdView setAdContentView:adView]; | |
| [self.mpAdView customEventDidLoadAd]; | |
| } | |
| - (void) tapForTapAdView: (TapForTapAdView *)adView didFailToReceiveAd: (NSString *)reason | |
| { | |
| // Signal to our MPAdView that the custom event failed to load an AdMob ad. | |
| [self.mpAdView customEventDidFailToLoadAd]; | |
| } | |
| - (void) tapForTapAdViewWasTapped: (TapForTapAdView *)adView | |
| { | |
| //Signal to our MPAdView that the user interacted with the custom event | |
| [self.mpAdView customEventActionWillBegin]; | |
| } | |
| #pragma mark MPAdViewDelegate Methods | |
| - (UIViewController *)viewControllerForPresentingModalView | |
| { | |
| return self; | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment