Created
September 9, 2013 23:15
-
-
Save pjlaird/6502787 to your computer and use it in GitHub Desktop.
iOS MoPub custom events for Tap for Tap SDK v3
This file contains 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
// | |
// Copyright (c) 2013 Tap for Tap. All rights reserved. | |
// | |
#import "MPInterstitialCustomEvent.h" | |
#import "TFTTapForTap.h" | |
@interface TFTMoPubInterstitial : MPInterstitialCustomEvent <TFTInterstitialDelegate> | |
@property (nonatomic, retain) TFTInterstitial *interstitial; | |
@end |
This file contains 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
// | |
// Copyright (c) 2013 Tap for Tap. All rights reserved. | |
// | |
#import "TFTMoPubInterstitial.h" | |
@implementation TFTMoPubInterstitial | |
- (id) init { | |
self = [super init]; | |
if (self) { | |
[TFTTapForTap initializeWithAPIKey:@"YOUR _API_KEY"]; | |
self.interstitial = [TFTInterstitial interstitialWithDelegate:self]; | |
} | |
return self; | |
} | |
- (void) dealloc { | |
self.interstitial = nil; | |
} | |
- (void)requestInterstitialWithCustomEventInfo:(NSDictionary *)info | |
{ | |
[self.interstitial load]; | |
// If Tap for Tap already has an interstitial ready let MoPub know | |
if (self.interstitial.readyToShow) { | |
[self.delegate interstitialCustomEvent:self didLoadAd:self]; | |
} | |
CLLocation *location = self.delegate.location; | |
if (location) { | |
[TFTTapForTap setLocation:location]; | |
} | |
} | |
- (void)showInterstitialFromRootViewController:(UIViewController *)rootViewController { | |
[self.interstitial showWithViewController:rootViewController]; | |
} | |
- (void)tftInterstitialDidReceiveAd:(TFTInterstitial *)interstitial { | |
[self.delegate interstitialCustomEvent:self didLoadAd:self]; | |
} | |
- (void)tftInterstitial:(TFTInterstitial *)interstitial didFail:(NSString *)reason { | |
[self.delegate interstitialCustomEvent:self didFailToLoadAdWithError:nil]; | |
} | |
- (void)tftInterstitialDidShow:(TFTInterstitial *)interstitial { | |
[self.delegate interstitialCustomEventDidAppear:self]; | |
} | |
- (void)tftInterstitialWasTapped:(TFTInterstitial *)interstitial { | |
[self.delegate interstitialCustomEventDidReceiveTapEvent:self]; | |
} | |
- (void) tftInterstitialWasDismissed:(TFTInterstitial *)interstitial { | |
[self.delegate interstitialCustomEventDidDisappear:self]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment