Guest User

Untitled

a guest
Jul 18th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. //
  2. // TapJoyController.h
  3. // libOpenAI
  4. //
  5. // Created by Aaron Alexander on 11/24/09.
  6. // Copyright 2009 AppAds. All rights reserved.
  7. //
  8.  
  9. #import "AdNetworkController.h"
  10. #if (USE_TAPJOY)
  11. #import "TapjoyConnect.h"
  12. #endif
  13.  
  14. #if (USE_TAPJOY)
  15.  
  16. // Our method to hook into tapjoys callback
  17. static void TJCAdController$tapjoyConnectDidReceiveAd$(TJCAdController *obj, SEL sel, BOOL status);
  18.  
  19. @interface TapJoyController : AdNetworkController <TapjoyConnectDelegate, TJCCustomAdsProtocol> {
  20. NSString *appID;
  21. NSString *appPassword;
  22. }
  23. @property (nonatomic, retain) NSString *appID;
  24. @property (nonatomic, retain) NSString *appPassword;
  25.  
  26.  
  27. #else
  28. @interface TapJoyController : AdNetworkController {
  29. }
  30. #endif
  31.  
  32.  
  33. @end
  34.  
  35.  
  36. //
  37. // TapJoyController.m
  38. // libOpenAI
  39. //
  40. // Created by Aaron Alexander on 11/24/09.
  41. // Copyright 2009 AppAds. All rights reserved.
  42. //
  43.  
  44. #import "TapJoyController.h"
  45.  
  46.  
  47. @implementation TapJoyController
  48. #if (USE_TAPJOY)
  49. @synthesize appID, appPassword;
  50.  
  51.  
  52. - (id)initWithDelegate:(id)aDelegate {
  53. if (self = [super initWithDelegate:aDelegate]) {
  54. self.delegate = aDelegate;
  55. }
  56. return self;
  57. }
  58.  
  59. - (void)parseParams:(NSString*)params {
  60.  
  61. }
  62.  
  63. - (void)setupNetworkWithFrame:(CGRect)aRect {
  64. //NSAssert(appID, @"The argument 'appID' cannot be nil.");
  65. //NSAssert(appPassword, @"The argument 'appPassword' cannot be nil.");
  66.  
  67. /* TapJoy doesnt expose a proper delegate callback when they load an ad internally
  68. So we need to hook an internal method to give us a proper callback so we really
  69. know when they recieved an ad. This can and will probably break when they upgrade
  70. their SDK so be warned! */
  71.  
  72. SwizzleMethod(objc_getClass("TJCAdController"), @selector(tapjoyConnectDidReceiveAd:), (IMP) (TJCAdController$tapjoyConnectDidReceiveAd$), "HOOK_");
  73.  
  74.  
  75.  
  76. // Setup TapJoy
  77. TapjoyConnect* tc = [TapjoyConnect requestTapjoyConnectWithDelegate:self];
  78. [tc getAdOrder];
  79. TJCAdView *ta = [[TapjoyConnect requestTapjoyConnectWithDelegate:self] showAdBox:1 rect:aRect];
  80. NSLog(@"TJ Subviews: %i", [[ta subviews] count]);
  81. [ta setDelegate:self];
  82. [self setAdView: ta];
  83. }
  84.  
  85. - (void)requestRefreshAd {
  86. NSLog(@"\n\n%@ Request fresh ad!\n\n", self.networkName);
  87. //[self.adView getNextAd];
  88. }
  89.  
  90. - (BOOL)waitsForDelegateToShowAd {
  91. return YES;
  92. }
  93.  
  94. - (NSString*)networkName {
  95. return @"tapjoy";
  96. }
  97.  
  98. - (void)dealloc {
  99. [appID release];
  100. [appPassword release];
  101. [self.adView release];
  102. [super dealloc];
  103. }
  104.  
  105.  
  106. #pragma mark -
  107. #pragma mark TJCAdController Swizzle
  108.  
  109. static void TJCAdController$tapjoyConnectDidReceiveAd$(TJCAdController *obj, SEL sel, BOOL status) {
  110. if (status == YES) {
  111. NSLog(@"\n\n%@ DID RECEIEVE AD!\n\n", self.networkName);
  112. [super didRecieveAd:self.adView];
  113. } else {
  114. [super didFailToRecieveAd:self.adView];
  115. }
  116. [obj HOOK_tapjoyConnectDidReceiveAd: status];
  117. }
  118.  
  119. #pragma mark -
  120. #pragma mark TapJoy Delegate
  121. // Use this to provide a application id for an application.
  122. - (NSString *)appID
  123. {
  124. return @"cc7ed992-f957-4842-a823-35fba221e3f2"; //your App Id Here
  125. }
  126.  
  127. // Use this to provide a application password for an application
  128. - (NSString *)appPassword
  129. {
  130. return @"503adad3-0046-4de1-b95d-3097dad7e59f"; // your app password here
  131. }
  132.  
  133. // Use this to provide a application version
  134. - (NSString *)appVersion
  135. {
  136. return @"1.2"; // your version here
  137. }
  138.  
  139.  
  140. //Optional: To Record the events at Pinch Media
  141.  
  142. -(NSString *) pinchMediaAppId
  143. {
  144. //Your Application's Pinch Id here.
  145. return nil;// @"6c9eb387046f95b0ccb919fe1b2f96ed";
  146.  
  147. }
  148.  
  149. - (void)didReceiveConnection:(id)connectionResult {
  150. NSLog(@"\n\n DID RECEIEVE CONNECTION!\n\n");
  151. // DONT KNOW IF WE HAVE AD, BUT I GUESS WE WILL ASSUME WE DO.
  152. }
  153.  
  154. - (void)didFailToReceiveConnection:(id)failedResult {
  155. [super didFailToRecieveAd:self.adView];
  156. }
  157.  
  158. - (void)showCustomAd:(TJCAdView*)adsObject {
  159. NSLog(@"\n\n%@ DID RECEIEVE AD!\n\n", self.networkName);
  160. NSLog(@"TJ Subviews: %i", [[self.adView subviews] count]);
  161. [super didRecieveAd:self.adView];
  162. }
  163.  
  164. -(void)endCustomAd:(TJCAdView*)adsObject {
  165. [super didFailToRecieveAd:self.adView];
  166. }
  167.  
  168. #endif
  169.  
  170. @end
Add Comment
Please, Sign In to add comment