Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // TapJoyController.h
- // libOpenAI
- //
- // Created by Aaron Alexander on 11/24/09.
- // Copyright 2009 AppAds. All rights reserved.
- //
- #import "AdNetworkController.h"
- #if (USE_TAPJOY)
- #import "TapjoyConnect.h"
- #endif
- #if (USE_TAPJOY)
- // Our method to hook into tapjoys callback
- static void TJCAdController$tapjoyConnectDidReceiveAd$(TJCAdController *obj, SEL sel, BOOL status);
- @interface TapJoyController : AdNetworkController <TapjoyConnectDelegate, TJCCustomAdsProtocol> {
- NSString *appID;
- NSString *appPassword;
- }
- @property (nonatomic, retain) NSString *appID;
- @property (nonatomic, retain) NSString *appPassword;
- #else
- @interface TapJoyController : AdNetworkController {
- }
- #endif
- @end
- //
- // TapJoyController.m
- // libOpenAI
- //
- // Created by Aaron Alexander on 11/24/09.
- // Copyright 2009 AppAds. All rights reserved.
- //
- #import "TapJoyController.h"
- @implementation TapJoyController
- #if (USE_TAPJOY)
- @synthesize appID, appPassword;
- - (id)initWithDelegate:(id)aDelegate {
- if (self = [super initWithDelegate:aDelegate]) {
- self.delegate = aDelegate;
- }
- return self;
- }
- - (void)parseParams:(NSString*)params {
- }
- - (void)setupNetworkWithFrame:(CGRect)aRect {
- //NSAssert(appID, @"The argument 'appID' cannot be nil.");
- //NSAssert(appPassword, @"The argument 'appPassword' cannot be nil.");
- /* TapJoy doesnt expose a proper delegate callback when they load an ad internally
- So we need to hook an internal method to give us a proper callback so we really
- know when they recieved an ad. This can and will probably break when they upgrade
- their SDK so be warned! */
- SwizzleMethod(objc_getClass("TJCAdController"), @selector(tapjoyConnectDidReceiveAd:), (IMP) (TJCAdController$tapjoyConnectDidReceiveAd$), "HOOK_");
- // Setup TapJoy
- TapjoyConnect* tc = [TapjoyConnect requestTapjoyConnectWithDelegate:self];
- [tc getAdOrder];
- TJCAdView *ta = [[TapjoyConnect requestTapjoyConnectWithDelegate:self] showAdBox:1 rect:aRect];
- NSLog(@"TJ Subviews: %i", [[ta subviews] count]);
- [ta setDelegate:self];
- [self setAdView: ta];
- }
- - (void)requestRefreshAd {
- NSLog(@"\n\n%@ Request fresh ad!\n\n", self.networkName);
- //[self.adView getNextAd];
- }
- - (BOOL)waitsForDelegateToShowAd {
- return YES;
- }
- - (NSString*)networkName {
- return @"tapjoy";
- }
- - (void)dealloc {
- [appID release];
- [appPassword release];
- [self.adView release];
- [super dealloc];
- }
- #pragma mark -
- #pragma mark TJCAdController Swizzle
- static void TJCAdController$tapjoyConnectDidReceiveAd$(TJCAdController *obj, SEL sel, BOOL status) {
- if (status == YES) {
- NSLog(@"\n\n%@ DID RECEIEVE AD!\n\n", self.networkName);
- [super didRecieveAd:self.adView];
- } else {
- [super didFailToRecieveAd:self.adView];
- }
- [obj HOOK_tapjoyConnectDidReceiveAd: status];
- }
- #pragma mark -
- #pragma mark TapJoy Delegate
- // Use this to provide a application id for an application.
- - (NSString *)appID
- {
- return @"cc7ed992-f957-4842-a823-35fba221e3f2"; //your App Id Here
- }
- // Use this to provide a application password for an application
- - (NSString *)appPassword
- {
- return @"503adad3-0046-4de1-b95d-3097dad7e59f"; // your app password here
- }
- // Use this to provide a application version
- - (NSString *)appVersion
- {
- return @"1.2"; // your version here
- }
- //Optional: To Record the events at Pinch Media
- -(NSString *) pinchMediaAppId
- {
- //Your Application's Pinch Id here.
- return nil;// @"6c9eb387046f95b0ccb919fe1b2f96ed";
- }
- - (void)didReceiveConnection:(id)connectionResult {
- NSLog(@"\n\n DID RECEIEVE CONNECTION!\n\n");
- // DONT KNOW IF WE HAVE AD, BUT I GUESS WE WILL ASSUME WE DO.
- }
- - (void)didFailToReceiveConnection:(id)failedResult {
- [super didFailToRecieveAd:self.adView];
- }
- - (void)showCustomAd:(TJCAdView*)adsObject {
- NSLog(@"\n\n%@ DID RECEIEVE AD!\n\n", self.networkName);
- NSLog(@"TJ Subviews: %i", [[self.adView subviews] count]);
- [super didRecieveAd:self.adView];
- }
- -(void)endCustomAd:(TJCAdView*)adsObject {
- [super didFailToRecieveAd:self.adView];
- }
- #endif
- @end
Add Comment
Please, Sign In to add comment