Latest 1.2.3
License Apache 2
Platforms ios 9.0, requires ARC
Dependencies SWXMLHash

iOS ViscoveryADSDK Integration


  • ViscoveryADSDK Account
  • Xcode
  • iOS 9.0
  • CocoaPods
$ sudo gem install cocoapods


Viscovery Ads SDK for iOS utilizes Appleā€™s advertising identifier (IDFA). The SDK uses IDFA under the guidelines laid out in the iOS developer program license agreement. You must ensure you are in compliance with the iOS developer program license agreement policies governing the use of this identifier.

Adding libraries to the Xcode project

Podfile Example

Add in your Podfile

pod 'ViscoveryADSDK'

or use latest version

pod 'ViscoveryADSDK', :git => ''

then execute

pod install

Once the command completed, open the .xcworkspace file in Xcode

Step by Step Implemention

Link to Full Source Code

1. Import SDK

import ViscoveryADSDK

2. Set API Key

Put these line before your ad request.

import ViscoveryADSDK
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    AdsManager.apiKey = "873cbd49-738d-406c-b9bc-e15588567b39"
    return true

3. Setup AdsManager

Before you started you have to setup your AVPlayer and UIView that AVPlayerLayer in it.

var contentPlayer: AVPlayer?
var adsManager: AdsManager!
@IBOutlet weak var outstreamContainer: UIView!

And initialize AdsManager

adsManager = AdsManager(player: contentPlayer!, 
                     videoView: videoContainer, 
        outstreamContainerView: outstreamContainer)

The you can request ads the video will start automatically.


Or request with videoId

adsManager.requestAds(videoURL: "your-video-id")

Full Example Source Code



This class only for demo. you should replace it with any view that has AVPlayerLayer in it.

class VideoView: UIView {
  var player: AVPlayer? {
    set {
      (self.layer as! AVPlayerLayer).player = newValue
    get {
      return (self.layer as! AVPlayerLayer).player
  override class var layerClass: AnyClass {
    return AVPlayerLayer.self
  required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    let tap = UITapGestureRecognizer(target: self, action: #selector(VideoView.tap))
  func tap() {
    player?.rate == 1.0 ? player?.pause() : player?.play()

Example Source Code Objective-C

@import ViscoveryADSDK;

@interface AppDelegate ()

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  AdsManager.apiKey = @"873cbd49-738d-406c-b9bc-e15588567b39";
  // Override point for customization after application launch.
  return YES;


@import ViscoveryADSDK;

@interface VideoView : UIView
@implementation VideoView
+ (Class) layerClass {
  return [AVPlayerLayer class];

@interface ViewController ()
@property(nonatomic,weak) IBOutlet VideoView *videoView;
@property(nonatomic,strong) AVPlayer *contentPlayer;
@property(nonatomic,strong) AdsManager *adsManager;

@implementation ViewController

- (void)viewDidLoad {
  [super viewDidLoad];

  NSURL *url = [[NSURL alloc]initWithString:@""];

  self.contentPlayer = [AVPlayer playerWithURL:url];
  ((AVPlayerLayer *)self.videoView.layer).player = self.contentPlayer;
  self.adsManager = [[AdsManager alloc] initWithPlayer:self.contentPlayer videoView:self.videoView];

  [self.adsManager requestAdsWithVideoURL:@""];

  //[self.adsManager requestAdsWithVideoURL:nil];


Latest podspec

    "name": "ViscoveryADSDK",
    "version": "1.2.3",
    "summary": "Viscovery VidSense SDK",
    "description": "Integrate with Google IMA and provide simple APIs.",
    "requires_arc": true,
    "pod_target_xcconfig": {
        "SWIFT_VERSION": "3.0"
    "homepage": "",
    "license": {
        "type": "Apache 2",
        "file": "LICENSE"
    "authors": {
        "boska lee": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.2.3"
    "platforms": {
        "ios": "9.0"
    "ios": {
        "frameworks": "AVFoundation"
    "source_files": "ViscoveryADSDK/Classes/**/*",
    "resources": "ViscoveryADSDK/Assets/*.xcassets",
    "dependencies": {
        "SWXMLHash": [
            "~> 3.0"
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This