iOS SDK Integration


Table of contents


  1. Intigrating tapCLIQ SDK
  2. Setting up Ad View
  3. Handle Device Rotation
  4. Requesting tag based ads
  5. Supporting ads on popover view
  6. Capture app launch and usage data
  7. Push Notification
  8. Important Note

[Do not miss points 4, 6 and 7]

 

  1. 1. Integrate tapCLIQ SDK


    Step 1 : Copy t2rBundle.bundle to the "Resources" folder in your project. Select "Copy items into destination group's folder (if needed)" in the pop up that follows once you drag the images into the Resources folder.

    Step 2 : Copy libt2rLibrary.a into the project's root folder.

    Step 3 : On the left hand side of XCode, in the file browser, click on the main project file. The right hand side view will expand the details.

     

    Select target and expand "Build Phases", under it, expand "Link Binary with Libraries".

     

    Add the following libraries:

    NOTE:

    AdSupport framework should be added for iOS 6 and higher (and so if your app supports lower version than it should be weakly linked i.e., Optional - as shown in the image below)

    CoreLocation.framework, CoreGraphics.framework, libsqlite3.0.dylib, MapKit.Framework, CFNetwork.framework, MobileCoreServices.framework, libz.dylib, SystemConfiguration.framework ( shown in Figure: 1 below )


    [Figure: 1 ]

     

    Step 4 : If "libt2rLibrary.a" does not show up in the "Link Binary with Libraries" tab, click on the '+' sign on the bottom left corner and click on "Add Other". Browse to libt2rLibrary.a which is copied in your project's root ( in step 2 ) and add it.

    Step 5 : Copy AdvBar.h to the "Classes" folder. Select "Copy items into destination group's folder (if needed)".

     

  2. 2. Setting up Ad view


    Step 1 : In the view controller's .m file, where you want the tapCLIQ ad bar, import AdvBar.h:

    #import "AdvBar.h"

    and put the below mentioned code in viewDidAppear.( Ad initialization followed by ad request notification, with your tag)

     

    if ( ab == nil) {
    
    	ab = [[AdvBar alloc] initWithAppId:@"Your app Id"
    	origin:CGPointMake(x_axis_of_the_bar,y_axis_of_the_bar) from:self
    	adType:@"Square_Ad"
    	adUnitId:particular_ad_unit_Id_registered_under_apporwebsite]; //2 in the example shown below
    	
    	// Based on the type of ad view you wish to integrate, adType can be @"Square_Ad" or @"FullScreen_Ad" or @"700x90" (Detail View of a SplitViewController) or @"1024x90" (Full Width) or @"Small_Ad" (for a 320x50 ad)
    
    	ab.tag =131313;
    	ab.mydelegate = self;
    	[self.view addSubView:ab]
    	
    }
    

     

    Research unit implementation
    OR [for Longer question / Answers and polls in size 300x250 (Medium Rectangle - MR), 720x300 (Pop under - PU) and 300x600 (Half Page - PU)]

     

    if ( ab == nil) 
    {
    	ab = [[AdvBar alloc] initWithAppId:@"Your app Id" origin:CGPointMake(x_axis_of_the_adunit,y_axis_of_the_adunit) from:self webadType:@"PU" adUnitId:particular_ad_unit_Id_registered_under_apporwebsite tag:String_ad_tag];
    
    	//example:
    	ab = [[AdvBar alloc] initWithAppId:@"a7380cf91c5347b688ea351c5d78157q" origin:CGPointMake(20.0,550.0) from:self webadType:@"PU" adUnitId:125 tag:@"testnola"];
    
    	Note: webadType value can be @"MR" (for 300x250 unit), @"PU" (for 720x300 unit), @"HP" (for 300x600 unit), @"Small_Ad" (for 320x50 unit)
    	ab.tag =232323;
    	ab.mydelegate = self;
    	[self.view addSubview:ab];
    }
    
    // Post a notification with your tag
    NSDictionary *dict = [[NSDictionary alloc] initWithObjects: [NSArray arrayWithObject:@"test"] forKeys: [NSArray arrayWithObject:@"Tags"]];
    
    [[NSNotificationCenter defaultCenter] postNotificationName: @"CustomTrigger" object: self userInfo: dict];
    				  

     

    Ad unit Id is the unit Id registered by you in under your app.



    [Figure: 2 ]

    NOTE:

    To get an App Id you need to sign in to your account and register your app under "My Apps" from left hand side panel.

     

  3. 3. Handle Device Rotations:


    In - (void)didRotateFromInterfaceOrientation: (UIInterfaceOrientation)fromInterfaceOrientation ,when the ad has to be re-oriented, call :

    - (void)adOrientationChanged:(int)interfaceOrientation xAxis:(float)x yAxis:(float)y adType:(NSString *)  type;				
    

     

    And Implement fetchNewAdPacket (delegate method) and post a custom trigger in that method too , if you wish to continue fetching new ad packets.

     

    - (void)fetchNewAdPacket:(AdvBar *)bar {
    
    	NSDictionary *dict = [[NSDictionary alloc] initWithObjects: [NSArray arrayWithObject:yourKeyword] forKeys: [NSArrayarrayWithObject:@"Tags"]];
    
    	[[NSNotificationCenter defaultCenter] postNotificationName: @"CustomTrigger" object: self userInfo: dict];
    	
    }

     

    For example :

     

    - (void)didRotateFromInterfaceOrientation:
    
    (UIInterfaceOrientation)fromInterfaceOrientation {
    	
    	if(UIInterfaceOrientationIsPortrait([[UIDevice currentDevice]orientation])) {
    	
    		[((AdvBar*) [self.view viewWithTag:1]) adOrientationChanged: [[UIDevice currentDevice] orientation] xAxis:x_axis_after_rotation 
    		yAxis:y_axis_after_rotation
    		adType:@"your_ad_type_same_as_in_initialization"];
    		
    	}
    	else {
    	
    		[((AdvBar*) [self.view viewWithTag:1]) adOrientationChanged [[UIDevice currentDevice] orientation] xAxis:x_axis_after_rotation
    		yAxis:y_axis_after_rotation
    		adType:@"your_ad_type_same_as_in_initialization"];		
    		
    	}
    }

     

    NOTE:
    Square Ad, 700x90 and 1024x90 Ad formats are only available for iPad

     

  4. 4. Requesting tag based ads


    For any custom trigger or moment specific Ad / Question invocation, you should post a tag based custom trigger notification.

    You can post a tag based notification as shown below

     

    For example:

    If you want to trigger Ads / Questions that match tag "coffee" and "cafe" then you should post a notification as in example 1

     

    Example 1:

     

    NSDictionary *dict = [[NSDictionary alloc] initWithObjects: [NSArray arrayWithObject: @"coffee,cafe"] 
    forKeys: [NSArray arrayWithObject:@"Tags"]];
    
    [[NSNotificationCenter defaultCenter] postNotificationName: @"CustomTrigger" object: self userInfo: dict];
    

     

    If you want to ask certain Questions or display a particular ad when your user reaches Level 2 . Than you should post a custom notification with tag "level2" when user just starts level 2. In response, campaigns matching the tag 'level2' will be displayed

    You can post this notification as in example 2

     

    Example 2:

     

    NSDictionary *dict = [[NSDictionary alloc] initWithObjects: [NSArray arrayWithObject: @"level2"] 
    forKeys: [NSArray arrayWithObject:@"Tags"]];
    
    [[NSNotificationCenter defaultCenter] postNotificationName: @"CustomTrigger" object: self userInfo: dict];

     

    If you want to trigger Ads / Questions which do not match particular tag(s) (Tag / Keyword exclusion) you should post a CustomTrigger notification with -ex

     

    Example 3:

     

    NSDictionary *dict = [[NSDictionary alloc] initWithObjects: [NSArray arrayWithObject: @"cafe-ex"] 
    forKeys: [NSArray arrayWithObject:@"Tags"]];
    
    [[NSNotificationCenter defaultCenter] postNotificationName: @"CustomTrigger" object: self userInfo: dict];

     

    Above example will display ads / Questions that do not have keyword "cafe"

     

    NOTE:

    Implement fetchNewAdPacket (delegate method) and post a custom trigger in that method too , IF you wish to have a continuous flow of ads (* matching campaigns must exist) OR support ad refresh on orientation change.

     

    - (void)fetchNewAdPacket:(AdvBar *)bar {
    	NSDictionary *dict = [[NSDictionary alloc] initWithObjects: [NSArray arrayWithObject:yourKeyword] 
    	forKeys: [NSArray arrayWithObject:@"Tags"]];
    	
    	[[NSNotificationCenter defaultCenter] postNotificationName: @"CustomTrigger" object: self userInfo: dict];
    }

     

     

    Delegate methods :

    To implement AdvBarProtocol delegate you need to specify it in .h file of the ViewController that has AdvBar integrated in it.

    @interface yourViewControllerWithAdvBar : UIViewController <AdvBarProtocol>

    And then implement any of the above optional methods in corresponding .m file.
    You can implement following optional delegate methods which notify your app when:

    - (BOOL)presentT2RBar:(AdvBar*)bar 
    {
    	// tapCLIQ ad view is about to be displayed.
    }
    - (void)removedT2RBar:(AdvBar*)bar 
    {
    	// tapCLIQ ad view is about to be removed from the view.
    }
    - (void)changeAd:(AdvBar *)bar 
    {
    	// Ad is going to change.
    }
    - (void)fetchNewAdPacket:(AdvBar *)bar 
    {
    	// Called when tapCLIQ is about to fetch a new ad packet
    }
    - (void)getUserSelection:(NSString *)data 
    {
    	// Called to notify user's selection in a Question-Answer ad ( by passing a tag/link )
    }
    - (void)adError:(NSString *)description 
    {
    	// Called when their is error with any tapCLIQ request
    }

     

  5. 5. In order to support interactive ads on a popover view implement below mentioned delegate method:


    - (UIPopoverController *)getViewControllerInchargeOfPopoverInPortarit
    {
    
    }
    

    wherein you should pass popover controller as shown in the e.g.below:

    - (UIPopoverController *)getViewControllerInchargeOfPopoverInPortarit
    {
    	return your_popovercontroller;
    }

     

     

  6. 6. Capture app launch and app usage data:


    In order to capture app launch and app usage data import AdvBar.h and add following lines of code in didFinishLaunchingWithOptions and - applicationDidEnterBackground methods of your appDeleage and import AdvBar.h in the appDelegate.m

     

    - (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    	[AdvBar tqSetUp];
    	[self.window makeKeyAndVisible];
    	return YES;
    }
    - (void)applicationDidEnterBackground:(UIApplication *)application {
    	__block UIBackgroundTaskIdentifier bgTask = [applicationbeginBackgroundTaskWithExpirationHandler:^
    	{
    		// Clean up any unfinished task business by marking where you stopped or ending the task outright.
    		[application endBackgroundTask:bgTask];
    		bgTask = UIBackgroundTaskInvalid;
    	}];
    	
    	// Start the long-running task and return immediately.
    	dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    		// Do the work associated with the task, preferably in chunks.
    		[AdvBar tqCleanUp];
    		[application endBackgroundTask:bgTask];
    		bgTask = UIBackgroundTaskInvalid;
    	});
    }

     

     

  7. 7. Push notifications


    Refer Push Notification document attached in the package for setting up & using push notifications

     

  8. 8. Important Note:


    • Please set advbar object properties to nil in it's parent view controller's dealloc.
      - (void)dealloc {
      	ab.timeOutForQuestion = nil;
      	ab.calledBy = nil;
      	ab = nil;
      }
    • Do not remove tapCLIQ ad bar object explicitly.
    • Implement fetchNewAdPacket method and perform a tag based ad request in it to continue fetching ads, once an ad packet is displayed.
    • Do not remove tapCLIQ ad bar object explicitly.

Back to Top