iOS SDK

This page describes how to install the AdGate Media iOS SDK.

Requirements

• iOS version 8.0 or higher

1. Install SDK

Installation with CocoaPods

  1. To install via CocoaPods, simply add the following line to your Podfile:

    pod 'AdGateMedia'
  1. Run pod install to install AdGateMedia dependency.

Installation with Framework (.framework)

  1. Download the AdGateMedia_UniversalFramework.zip file from the Releases page. Drag and drop AdGateMedia.framework and AdGateMedia.bundle into your project. (Note that when you would like to upload your app to app store you must use device only version which is AdGateMedia_DeviceFramework.zip otherwise your app will be rejected Radar)

  2. Go to General/Linked Frameworks and Libraries and add AVFoundation.framework, AdSupport.framework CoreMedia.framework, and WebKit.framework.

  3. Go to Build Settings/Linking/Other Linker Flags and add -ObjC flag.

  4. Make sure Build Settings/Search Paths/Framework Search Paths includes the path of our framework, Otherwise add framework path. For example if your framework exist in your project directory then you could add $(PROJECT_DIR) .

  5. Make sure AdGateMedia.bundle is added in Build Phases/Copy Bundle Resources.

Installation with Library (.a)

  1. Download the AdGateMediaLibrary.zip file from the Releases page. Drag and drop libAdGateMedia.a, AdGateMedia.bundle and include folder into your project. (Note that when you would like to upload your app to app store you must use device only version which is AdGateMedia_DeviceLibrary.zip otherwise your app will be rejected Radar)

  2. Go to General/Linked Frameworks and Libraries and add AVFoundation.framework, AdSupport.framework CoreMedia.framework, and WebKit.framework.

  3. Go to Build Settings/Linking/Other Linker Flags and add -ObjC flag.

  4. Make sure Build Settings/Search Paths/Library Search Paths includes the path of our library, otherwise add library path. For example if library exist in project directory then you could add $(PROJECT_DIR).

  5. Make sure AdGateMedia.bundle is added in Build Phases/Copy Bundle Resources.

  6. Go to Build Settings/Search Paths/Header Search Paths and add $(PROJECT_DIR)/include or actual directory path where library header file copied.

In order to get started you are required to add the following header file to either your project's .pch file or at the location you are displaying the offer wall:

#import "AdGateMedia.h" //#import <AdGateMedia/AdGateMedia.h> if using framework

Installation in Swift project

Follow all bullet points of installation steps mentioned above and do these additional steps.

  1. Create Bridging header file (If not already created). It's name should be ${YOURPROJ}-Bridging-Header.h while ${YOURPROJ} is your project name.

  2. If you created bridging header manually then Go to Build Settings->Swift Compiler - General->Objective-C Bridging Header and add bridging header manually by specifying $(PROJECT_DIR)/$(PROJECT_NAME)/$(PROJECT_NAME)-Bridging-Header.h

  3. In the Bridging header file, import your framework using the standard Objective C import syntax. In our case, it will be

    #import <AdGateMedia/AdGateMedia.h>

    Note

  4. Please note that method names may be little bit shorter when you use this framework inside swift project.

  5. We have included a demo project written in swift for your convenience.

2. Load & Display the Offer wall

Add the following lines of code where you want to launch the offer wall:

@implementation ViewController

-(void)showOfferWall {

    NSString * rewardCode = @"YOUR_WALL_CODE";
    NSString * userId = @"YOUR_USER_ID";

    AdGateMedia *media = [[AdGateMedia alloc] initWithRewardCode:rewardCode userId:userId parentViewController:self];

    NSDictionary *parameter = @{
        @"s2" : @"Value s2",
        @"s3" : @"Value s3",
        @"s4" : @"Value s4",
        @"s5" : @"Value s5",
        };

    //Below code will show offer wall immediately before loading
    BOOL success = [media loadOfferWall: parameter onOfferWallLoadSuccess:^{

        NSLog(@"Successfully loaded wall");

    } OnOfferWallLoadFailed:^(NSError *error){

        NSLog(@"Failed to load wall");

    }];

    if (success) {

        [self.adGateMedia showOfferWall:^{

            NSLog(@"Closed wall");

        }];
    }
}

@end

To change the offer wall code and user name, use the following code:

@interface ViewController : UIViewController

@property (nonatomic, strong) AdGateMedia *media;

@end


@implementation ViewController

-(void)showOfferWall {

    NSString * rewardCode = @"YOUR_WALL_CODE";
    NSString * userId = @"YOUR_USER_ID";

    if (self.media == nil)
    {
        self.media = [[AdGateMedia alloc] initWithRewardCode:rewardCode userId:userId parentViewController:self];
    } else {
        self.media.rewardCode = rewardCode;
        self.media.userId = userId;
    }

    NSDictionary *parameter = @{
        @"s2" : @"Value s2",
        @"s3" : @"Value s3",
        @"s4" : @"Value s4",
        @"s5" : @"Value s5",
    };

    //Below code will show offer wall once it's loaded successfully
    [self.media loadOfferWall: parameter onOfferWallLoadSuccess:^{

        [media showOfferWall:^{

            NSLog(@"Closed wall");

        }];

    } OnOfferWallLoadFailed:^(NSError *error){

        NSLog(@"Failed to load wall");

    }];
}

@end

Set the rewardCode and userId to the appropriate values. You may get your wall code from this page on the affiliate dashboard.

  1. You can pass subids while loading the offer wall, specifically, s2, s3, s4 and s5.

  2. Once the offer wall is loaded you can display it using the showOfferWall method. User can see it called in the above code after the wall is successful loaded.

    [media showOfferWall:^{
        NSLog(@“Closed wall”);
    }];

3. Get a list of the latest offer wall conversions

To get the list of the latest offer wall conversions, use the getConversions method. Add the following lines of code in your class (i.e ViewController)

    NSString * rewardCode = @"YOUR_WALL_CODE";
    NSString * userId = @"YOUR_USER_ID";

    AdGateMedia *media = [[AdGateMedia alloc] initWithRewardCode:rewardCode userId:userId parentViewController:self];

    NSDictionary *parameter = @{
        @"s2" : @"Value s2",
        @"s3" : @"Value s3",
        @"s4" : @"Value s4",
        @"s5" : @"Value s5",
    };

    [media getConversions:parameter rewardCode:rewardCode userId:userId completionHandler:^(NSArray * _Nullable offers, NSError * _Nullable error) {
        if (error) {
            NSLog(@"Error: %@",error);
            //Show error
        }else {
            //Show offers
            NSLog(@"offers: %@",offers);
        }
    }];

4. Debug mode:

Step 1: Select the Edit Scheme from XCode where you set your active scheme.

Step 2: Goto Run -> Info -> Build Configuration -> Debug option -> Close.

Note: Use NSLog to print result after selecting the Debug build configuration. NSLog is used to print the value in the console for debug mode.

5. Demo App.

This repository contains a demo iOS app that shows how to implement our SDK.

Last updated