GumGumiOSSDK 0.2.7

GumGumiOSSDK 0.2.7

许可证 自定义
发布上次发布2015年10月

Jake Peterson维护。



GumGum iOS SDK

GumGum是一家领先的图片和屏幕内广告平台,为广告商提供品牌参与度,为出版商带来跨所有屏幕的收入增长。

特性

  • [x] 支持 Swift 和 Objective-C
  • [x] Cocoapods 支持
  • [x] 原生灯箱视频广告
  • [x] 支持图片广告、屏幕内广告和原生广告
  • [x] 支持 OpenRTB 2.3 规范

要求

  • iOS 7.1+

沟通

  • 如果您需要帮助,请使用Stack Overflow。(标签 'GumGum')
  • 如果您想提出一般性问题,请使用Stack Overflow
  • 如果您发现了一个错误,请提出一个问题。
  • 如果您有功能请求,请提出一个问题。

安装

另外,如果您想手动安装框架

1) 在您的目标“与库链接”中链接所需的框架:安装步骤 1 注意: MessageUI.framework 是可选的

2) 将 GumGumiOSSDK.framework 链接到您的目标:安装步骤 2

3) 将 GumGumiOSSDK.bundle 添加到您的目标“复制包资源”构建阶段:安装步骤 3

4) 将 -ObjC 编译器标志添加到项目目标构建设置的“其他链接器标志”中。

5) 构建您的项目(+B),以确保一切正常工作。

开始使用

#import <GumGumiOSSDK/GumGumiOSSDK.h>

设置您应用程序的信息。这应在您的 App Delegate 中或在尽可能早的时间进行。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Make sure you have setup your keyWindow first.
    [window makeKeyAndVisible];

    NSURL *url = [NSURL URLWithString:@"your app store url or website url"];
    [GumGumSDK initializeWithZoneId:@"your zone ID" appStoreURL:url isPaid:YES];

    return YES;
}

一旦设置完成,您可以选择以下 4 种不同类型的广告产品


获取原生广告

[GGNativeAdManager getNativeAdForSize:CGSizeMake(320, 100)
                          placementId:// Your placement id (provided by GumGum)
               viewControllerDelegate:// A UIViewController conforming to GGAdDelegate
                           completion:^(GGNativeAd *nativeAd, NSError *error) {
    // Your logic for displaying the native ad

    /* GGNativeAd model contains:
     *  title
     *  adDescription
     *  imageView.image or imageUrl
     *  sponsoredBy
     */
}];

获取图片内广告

GGInImageView 继承您希望广告放置的 UIImageView

如果您使用 Storyboards,您需要将 UIImageView 的 "Custom Class" 字段更改为 GGInImageView

In-Image custom class example

-viewDidLoad (或初始化后调用的任何方法)中

- (void)viewDidLoad {
    [super viewDidLoad];

    // All values are required
    GGInImageView *imageView = [[GGInImageView alloc] init];
    imageView.imageURL = [NSURL URLWithString:@"http://gumgum.com"];
    imageView.pageURL = [NSURL URLWithString:@"http://gumgum.com"];
    imageView.delegate = // A UIViewController conforming to GGAdDelegate

    // The ad will NOT start loading until an image with at least 120px height is set.
    imageView.image = [UIImage alloc] init];
}

UIViewControllerGGAdDelegate 匹配

@interface YourViewController: UIViewController <GGAdDelegate>

获取屏幕内广告

屏幕内广告由 UINavigationController 的一个实例控制。

UIViewController *viewController = [[UIViewController alloc] init];
GGInScreenNavigationController *navigationController = [[GGInScreenNavigationController alloc] initWithRootViewController:viewController];
navigationController.pageURL = [NSURL URLWithString:@"http://gumgum.com"];
navigationController.keywords = @"An, ad, is, worth, a, million, billion, impressions";

请记住,屏幕内广告在视图控制器展示之间保持状态。要控制哪些视图控制器显示广告,只需将您想显示广告的视图控制器与 GGAdDelegate 匹配即可。

如果您将视图控制器与 GGAdDelegate 匹配以显示 GGInImageView,但同时也想不显示屏幕内广告,只需设置导航控制器上的 inScreenHidden 属性

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    if ([self.navigationController conformsToProtocol:@protocol(GGAdDelegate)]) {
        GGInScreenNavigationController *navController = (GGInScreenNavigationController *)self.navigationController;
        [navController setInScreenHidden:YES animated:YES];
    }
}

// Don't forget to restore inScreenHidden when leaving that view controller!
- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];

    if ([self.navigationController conformsToProtocol:@protocol(GGAdDelegate)]) {
        GGInScreenNavigationController *navController = (GGInScreenNavigationController *)self.navigationController;
        [navController setInScreenHidden:NO animated:YES];
    }
}

获取信息流内广告

使用 GGInFeedDataSource 匹配管理您希望在其中显示广告的 UITableView 的实例。

在您想要开始加载数据流内广告的时间

CGSize size = CGSizeMake(300, 100);
id <GGInFeedDataSource> dataSource = // An instance conforming to GGInFeedDataSource
UIViewController <GGAdDelegate>*viewController = // An instance of UIViewController that conforms to GGAdDelegate
[[GGInFeedManager sharedManager] getInFeedAdWithSize:size
                                         placementId:// Your placement id (provided by GumGum)
                                           indexPath:// Optional. If you wish to specify exactly where the ad should be placed.
                                          dataSource:dataSource
                                            delegate:delegate];

根据需要,为您的 UITableView 提供辅助方法,以适应原生广告的显示。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    NSUInteger rows = // Number of rows you plan to show in this section
    NSUINteger nativeAdCount = [[GGInFeedManager sharedManager] nativeAdCountForSection:section];
    return rows + nativeAdCount;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    // Your UITableViewCell setup logic

    GGNativeAd *nativeAd = [[GGInFeedManager sharedManager] nativeAdAtIndexPath:indexPath cell:cell];
    if (nativeAd) {
        // Your logic for displaying the native ad
    } else {
        // Your normal cell display implementation

        // Keep in mind you'll want to offset the array of data you are
        // normally displaying. Here is a rough example...
        NSArray *rowItems = @[];
        NSDictionary *cellInfo = rowItems[indexPath.row + offset]; // You should always add the offset!
    }

    return cell;
}

更多文档可以在这里找到 http://cocoadocs.org/docsets/GumGumiOSSDK/0.1.1/.

就是这样!

联系方式

关注 GumGum 的 Twitter (@GumGum

作者

Jake Peterson (@jakenberg

许可