Latest 1.0.4
Homepage https://github.com/camment/ads-ios
License MIT
Platforms ios 8.0
Dependencies AFNetworking
Frameworks UIKit
Authors

CammentAds for iOS

To get started with the CammentAds for iOS you can use the existing demo application project, or you can use the library in your existing project.

Technical requirements

  • Xcode 7 or later
  • iOS 8.1 or later
  • Cocoapods

Add CammentAds to your project

Open yout Podfile and add pod 'CammentAds' there

platform :ios, '8.1'

target 'Your target' do
    pod 'CammentAds'
end

then run pod install

Configuring CammentAds

Open your AppDelegate file and configure sdk with an api key

// import SDK
#import <CammentAds/CMACammentAds.h>

...    

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[CMACammentAds sharedInstance] configureWithApiKey:@"YOUR_API_KEY"];

    return YES;
}

Retrieving CammentAd Banner

//Create CMAShowMetadata object and set CMAShowMetadata fields according to your current video show to get more relevant banner
CMAShowMetadata *showMetadata = [CMAShowMetadata new];
showMetadata.title = @"friends";
showMetadata.genre = @"comedy";
showMetadata.isLive = true;
showMetadata.uuid = @"test_comedy_show";
showMetadata.length = 20;

//time to retrieve a banner!
[[CMACammentAds sharedInstance] getPrerollBannerForShowWithMetadata:showMetadata
                                                            success:^(CMABanner *banner) {
                                                                // now you'ready to show the banner
                                                                [self displayBanner:banner];
                                                            }
                                                            failure:^(NSError *error) {
                                                                NSLog(@"error %@", error);

                                                            }];

Adding BannerView into your layout

  1. Add a property to keep reference to the bannerView to your view controller
@interface CMAViewController ()

@property (nonatomic, weak) CMABannerView *bannerView;

@end
  1. Make sure you set a correct layout the banner
- (void)viewDidLayoutSubviews {
    if (_bannerView) {
        _bannerView.frame = self.view.bounds;
    }
}
  1. Show the banner with BannerView
- (void)displayBanner:(CMABanner *)banner {
    if (!banner) { return; }
    CMABannerView *cmaBannerView = [[CMABannerView alloc] initWithBanner:banner
                                                     bannerDeletionBlock:^{
                                                         [UIView animateWithDuration:0.3
                                                                          animations:^{
                                                                              self.bannerView.alpha = .0f;
                                                                          }
                                                                          completion:^(BOOL finished) {
                                                                              [self.bannerView removeFromSuperview];
                                                                          }];
                                                     }];

    self.bannerView = cmaBannerView;
    [self.view addSubview:cmaBannerView];
}

Take a look at bannerDeletionBlock – it should contain the code that removes banner from viewcontroller but having animations there is not required

Latest podspec

{
    "name": "CammentAds",
    "version": "1.0.4",
    "summary": "CammentAds SDK",
    "description": "CammentAds provides api for displaying ads banners via Camment platform.",
    "homepage": "https://github.com/camment/ads-ios",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Camment OY": "[email protected]"
    },
    "source": {
        "git": "https://github.com/camment/ads-ios.git",
        "tag": "1.0.4"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "CammentAds/Classes/**/*",
    "public_header_files": "CammentAds/Classes/**/*{.h}",
    "frameworks": "UIKit",
    "dependencies": {
        "AFNetworking": [
            "~> 3"
        ]
    }
}

Pin It on Pinterest

Share This