Skip to content

Getting Started

nook edited this page Aug 22, 2016 · 1 revision

Getting Started

This document details the process of integrating the Yieldmo SDK with your mobile application.

Requirements

The Yieldmo SDK only works with iOS 8.0 and above.

Install the Yieldmo SDK Cocoapod

The recommended way of installing the Yieldmo SDK is via Cocoapods.

  1. Add YieldmoSDK to your Podfile in your project directory. Example:

    source 'https://github.com/CocoaPods/Specs.git'
    
    target 'YourAppName' do
        pod 'YieldmoSDK', '~> 4.0.0'
    end
    
  2. In the same directory as your Podfile run the command pod install.

  3. Follow our Integration Guide to render Yieldmo ads in your app.

Alternate Installation

If you prefer not to use Cocoapods, our SDK is also distributed as a framework that you can include into your application manually.

  1. Download the Yieldmo SDK here.
  2. Unzip the Yieldmo SDK.
  3. Drag Yieldmo.framework into your Xcode application group (be sure to check the "Copy items into destination group's folder" option).
  4. Follow our Integration Guide to render Yieldmo ads in your app.

Ad Integration for iOS

Yieldmo ads usually appear within scrollable content. Adding one to your app takes just a few lines of code.

Steps to integrate an Ad for a placement:

  • Initialize Yieldmo in your AppDelegate:
/* Objective-C */

@import Yieldmo;
...

// Initialize SDK
[Yieldmo startWithAppID: kDemoAppID];
/* Swift */

import Yieldmo
...

// Initialize SDK
Yieldmo.startWithAppID(kDemoAppID)

Note: The sample code above uses a demo app ID. Please contact your Yieldmo representative to obtain your own unique app ID. Learn more about app ID's in Before You Launch.


  • In your custom ViewController, add a strong reference to a YMPlacementView, initialize it, and add it as a subview where appropriate:
/* Objective-C */

// Declare a strong property to hold the ad view
@property (nonatomic, strong) YMPlacementView * adView;

...

// Initialize the view
self.adView = [Yieldmo placementWithFrame: CGRectMake(0, 0, 320, 200)
                                   WithID: kDemoPlacement_Postcard];

...

// Add it as a subview where you want it displayed
[self.view addSubview:self.adView];
/* Swift */

// Declare a property to hold the ad view
var adView: YMPlacementView?

...

// Initialize the view
adView = Yieldmo.placementWithFrame(CGRectMake(0, 0, 320, 200), withID: kDemoPlacement_Postcard)

...

// Add it as a subview where you want it displayed
view.addSubview(adView!)

Note: The sample code above uses a demo placement ID. Please contact your Yieldmo representative to obtain your own unique placement IDs. Learn more about placement ID's in Before You Launch.


  • Make your custom ViewController conform to the YMPlacementViewDelegate protocol and implement the following required method:
/* Objective-C */

// Conform to YMPlacementViewDelegate
@interface ViewController : UIViewController <YMPlacementViewDelegate>

// Assign the placement view's delegate
self.adView.delegate = self;

// Implement required delegate method to give permission for ad resizing:
#pragma mark - YMPlacementViewDelegate methods

- (BOOL) adViewShouldResize: (YMPlacementView *) placementView toPosition: (CGRect) position {
    return YES;
}
/* Swift */

// Conform to YMPlacementViewDelegate
class ViewController: UIViewController, YMPlacementViewDelegate {

// Assign the placement view's delegate
adView!.delegate = self

// Implement required delegate method to give permission for ad resizing:
// MARK: - YMPlacementViewDelegate methods

func adViewShouldResize(placementView: YMPlacementView, toPosition position: CGRect) -> Bool {
  return true
}

Note: To find out more about all the available YMPlacementViewDelegate methods, see our YMPlacementViewDelegate page.

Clone this wiki locally