IOS SDK
From wiki.taptica.com
(Difference between revisions)
(Created page with " == iOS Integration== You can serve native, interstitial and banner ads very quickly and with little effort using Taptica SDK. == Download the Taptica iOS SDK == Download t...") |
Latest revision as of 07:44, 4 May 2015
Contents |
[edit] iOS Integration
You can serve native, interstitial and banner ads very quickly and with little effort using Taptica SDK.
[edit] Download the Taptica iOS SDK
Download the Taptica SDK. The download contains both the HydraSDK framework and the HydraResources bundle.
[edit] Integrate the SDK With Your App
Once you have downloaded the Hydra SDK, follow these steps to integrate the SDK with your app:
- . Linked frameworks:
- AVfoundation
- CoreTelephony
- AdSupport
- WebKit
- . Linking the HydraSDK:
- Open the HydraSDK folder and drag the HydraSDK.framework into the frameworks.
- Drag the Resources.bundle into the project files.
- Select your project target, in the ‘build settings’ section look for ‘other linker flags’ and add -ObjC flag.
You can clone the HydraSDKDemo which demonstrate how to create a banner ad and interstitial ad: [1]
[edit] Creating Banner Ad:
#import <HydraSDK/HydraSDK.h>
@interface ViewController () <HAdBannerDelegate> {
HAdBanner *banner;
__weak IBOutlet UIView *bannerHolderView;
}
@end
@implementation ViewController
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if (!banner) {
banner = [[HAdBanner alloc] initWithAdSize:(CGSize){320, 50}
origin:CGPointZero];
banner.unitAdID = @"115";
banner.delegate = self;
banner.rootViewController = self;
banner.requestParams.shouldOpenInNativeBrowser = YES;
[banner loadAd];
[bannerHolderView addSubview:banner];
}
}
You can listen to all ads events using the HAdBannerDelegate methods:
/// Called when an ad request loaded an ad. This is a good opportunity to add this view to the /// hierarchy if it has not been added yet. - (void)adViewDidReceiveAd:(HAdBanner *)adView; /// Called when an ad request failed. Normally this is because no network connection was available /// or no ads were available (i.e. no fill). - (void)adView:(HAdBanner *)adView didFailToReceiveAdWithError:(NSError *)error; #pragma mark Click-Time Lifecycle Notifications /// Called just before presenting the user a full screen view, such as a browser, in response to /// clicking on an ad. Use this opportunity to stop animations, time sensitive interactions, etc. /// /// Normally the user looks at the ad, dismisses it, and control returns to your application by /// calling adViewDidDismissScreen:. However if the user hits the Home button or clicks on an App /// Store link your application will end. On iOS 4.0+ the next method called will be /// applicationWillResignActive: of your UIViewController /// (UIApplicationWillResignActiveNotification). Immediately after that adViewWillLeaveApplication: /// is called. - (void)adViewWillPresentScreen:(HAdBanner *)adView; /// Called just before dismissing a full screen view. - (void)adViewWillDismissScreen:(HAdBanner *)adView; /// Called just after dismissing a full screen view. Use this opportunity to restart anything you /// may have stopped as part of adViewWillPresentScreen:. - (void)adViewDidDismissScreen:(HAdBanner *)adView; /// Called just before the application will background or terminate because the user clicked on an /// ad that will launch another application (such as the App Store). The normal /// UIApplicationDelegate methods, like applicationDidEnterBackground:, will be called immediately - (void)adViewWillLeaveApplication:(HAdBanner *)adView;
[edit] Creating Interstitial Ad:
Update the private interface:
@interface ViewController () <HAdBannerDelegate, HInterstitialDelegate>{
HAdBanner *banner;
HInterstitial *interstitial;
__weak IBOutlet UIView *bannerHolderView;
}
@end
- (IBAction)presentInterstitial:(UIButton *)sender {
interstitial = [[HInterstitial alloc] init];
interstitial.unitAdID = @"113";
interstitial.delegate = self;
[interstitial loadAd];
}
Present the Interstitial controller when the ad is ready, you can listen to the interstitialDidReceiveAd: method.
#pragma mark HInterstitialDelegate
- (void)interstitialDidReceiveAd:(HInterstitial *)ad {
[ad presentFromRootViewController:self];
}