Created
September 24, 2015 20:36
-
-
Save MaxGabriel/d0ce20fc5a15406e6472 to your computer and use it in GitHub Desktop.
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
| BOOL hz_chartboost_enabled(void) { | |
| return [HeyzapAds isNetworkInitialized:HZNetworkChartboost]; | |
| } | |
| // Calling hz_fetch_chartboost_for_location recursively won't keep the `const char *` in memory | |
| // Since I want to call it recursively, I immediately convert to an `NSString *` in `hz_fetch_chartboost_for_location` | |
| void hz_fetch_chartboost_for_location_objc(NSString *location) { | |
| if (!hz_chartboost_enabled()) { | |
| NSLog(@"Chartboost not enabled; in 0.25 seconds"); | |
| dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ | |
| hz_fetch_chartboost_for_location_objc(location); | |
| }); | |
| return; | |
| } | |
| NSLog(@"Caching Chartboost interstitial for location: %@",location); | |
| [HZUnityAdapterChartboostProxy cacheInterstitial:location]; | |
| } | |
| void hz_fetch_chartboost_for_location(const char *location) { | |
| NSString *nsLocation = [NSString stringWithUTF8String:location]; | |
| hz_fetch_chartboost_for_location_objc(nsLocation); | |
| } | |
| bool hz_chartboost_is_available_for_location(const char *location) { | |
| NSString *nsLocation = [NSString stringWithUTF8String:location]; | |
| if (!hz_chartboost_enabled()) { | |
| NSLog(@"Chartboost ad is not available because it is not enabled"); | |
| return NO; | |
| } | |
| const BOOL hasAd = [HZUnityAdapterChartboostProxy hasInterstitial:nsLocation]; | |
| NSLog(@"Chartboost says it has an ad = %i",hasAd); | |
| return hasAd; | |
| } | |
| void hz_show_chartboost_for_location(const char *location) { | |
| NSString *nsLocation = [NSString stringWithUTF8String:location]; | |
| if (!hz_chartboost_enabled()) { | |
| NSLog(@"Chartboost not enabled yet; not able to show ad."); | |
| return; | |
| } | |
| NSLog(@"Requesting Chartboost show interstitial for location: %@",nsLocation); | |
| [HZUnityAdapterChartboostProxy showInterstitial:nsLocation]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment