CPCMobCPCDK
安装
CPCMobCPCDKTest 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile 中
pod 'CPCMobCPCDK'
作者
许可证
CPCMobCPCDKTest 在 MIT 许可证下提供。有关更多信息,请参阅 LICENSE 文件。
CPCMobCPCDK iOS 接口文档
1.0 SDK介绍
提供请求接口,通过广告位ID、广告位类型、尺寸等信息获取广告。SDK包含真机和模拟器两种架构。
2.0 SDK要求
最低支持iOS 8.0,关闭bitcode并添加-ObjC。
3.0 暂无
4.0 接口说明
4.1 sharedInstance
+ (CPCCoreServer *)sharedInstance;
4.1.1 解释说明
以单例方式创建广告SDK对象
4.1.2 例
[CPCCoreServer sharedInstance]
4.2 initWithCPCKey
- (BOOL)initWithCPCKey:(NSString *)patchKey;
4.2.1 解释说明
初始化SDK,并传递更新用的密钥
4.2.2 例
[[CPCCoreServer sharedInstance] initWithCPCKey:@"XXXXXX"];
4.2.3 参数说明
参数 | 说明 |
---|---|
patchKey | 密钥,目前可随意传递值 |
4.3 cpcGetADModel:adviewConfig success:failure
- (void)cpcGetADModel:(CPCAdViewConfig *)adviewConfig
success:(void (^)(CPCADViewConfigModel * adViewModel))success
failure:(void (^)(NSError * error))failure;
4.3.1 解释说明
输入参数,并异步返回广告model。
4.3.2 例
[[CPCCoreServer sharedInstance] getAdViewWithParameters:adBody delegate:self adViewSetting:setBody success:^(UIView *adView) {
} failure:^(NSError *error) {
}];
4.3.4 参数说明
参数 | 说明 |
---|---|
adviewConfig | CPCAdViewConfig实例,alloc init 初始化 |
success | 广告请求成功的回调 |
failure | 广告请求失败,或者无广告的回调 |
CPCAdViewConfig * config = [[CPCAdViewConfig alloc] init];
config.adid = adid;
UIEdgeInsets edgeInset;
edgeInset.top = 10;
edgeInset.left = 10;
edgeInset.right = 10;
edgeInset.bottom = 10;
config.edgeInset = edgeInset;
config.titleImageOffset = 10;
config.titleFont = [UIFont systemFontOfSize:18];
config.imageOffset = 10;
adviewConfig字典 | 说明 |
---|---|
adid | 广告位id |
type | 广告位类型 |
width | 广告位宽度尺寸 |
height | 广告位高度尺寸 |
titleImageOffset | 文字到图片的间距 |
imageOffset | 图片间距 |
edgeInset | 图片或文字距离边界上下左右边距 |
clickSize | 点击区域大小(米读小说用) |
picType | 左图还是右图(米读小说用) |
4.3.5 广告位id
参数字典 | 说明 |
---|---|
7277638 | 组图测试广告位 |
7479036 | 图文测试广告位 |
7112926 | 大图测试广告位 |
4.5 cpcAdViewForHeight
- (CGFloat)cpcAdViewForHeight:(CPCADViewConfigModel *)adViewModel;
4.5.1 解释说明
根据物料model,计算ADView的高度,如果不用这个方法,用ADView.frame.size.height同样可以获取高度
4.5.2 例
CGFloat adHeight = [[CPCCoreServer sharedInstance] adViewForHeight:adViewModel]
4.5.3 参数说明
参数 | 说明 |
---|---|
adViewModel | 上一个方法请求回来的adViewmodel物料 |
4.6 cpcShowView:setDelegate
- (UIView *)cpcShowView:(CPCADViewConfigModel *)adViewModel
setDelegate:(id<CPCADViewDelegate>)delegate;
4.6.1 解释说明
通过物料model获取广告view
4.6.2 例
UIView * adView = [[CPCCoreServer sharedInstance] cpcShowView:adViewModel setDelegate:self];
4.6.3 参数说明
参数 | 说明 |
---|---|
adViewModel | getADModel方法请求回来的adViewmodeol物料 |
4.7 setLogEnable
+ (void)setLogEnable:(BOOL)flag;
4.7.1 解释说明
log 输出开关 , 默认关闭, YES开启
4.7.2 例
[CPCCoreServer setLogEnable:YES];
4.7.3 参数说明
参数 | 说明 |
---|---|
flag | NO:关闭 YES:开启 |
4.8 cpcGetLaunchADView:body:window:success:failure:failure;
- (void)cpcGetLaunchADView:(CPCLaunchAdViewConfig *)config
body:(NSDictionary *)parameters
window:(UIWindow *)window
success:(void (^)(NSObject * adViewModel))success
failure:(void (^)(NSError * error))failure;
4.8.1 解释说明
传输请求参数,和配置参数,请求开屏需要放到Appdelegate的application:didFinishLaunchingWithOptions中[self.window makeKeyAndVisible]后面
4.8.2 例
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
self.window.rootViewController = [storyBoard instantiateViewControllerWithIdentifier:@"ViewController"];
[self.window makeKeyAndVisible];
/********************** 开屏广告 *****************/
CPCLaunchAdViewConfig * config = [[CPCLaunchAdViewConfig alloc]init];
config.waitTime = 2.5;
config.showTime = 6;
config.animate = 1;
NSMutableDictionary * adBody = [[NSMutableDictionary alloc]initWithCapacity: 4];
[adBody setObject:@"7090271" forKey:@"id"];
[CPCCoreServer sharedInstance].launchDelegate = self;
[[CPCCoreServer sharedInstance] cpcGetLaunchADView:config body:adBody window:self.window success:^(NSObject *adViewModel) {
} failure:^(NSError *error) {
}];
/********************** 开屏广告 *****************/
4.8.3 参数说明
参数 | 说明 |
---|---|
config | NO:关闭 YES:开启 |
parameters | 请求必要参数 |
window | 当前的window |
failure | 失败回调 |
4.9 cpcConfigWithFont
- (CGFloat)cpcConfigWithFont:(UIView *)adView font:(UIFont*)font;
4.9.1 解释说明
提供广告对象,和字体对象,改变广告界面的字体,返回刷新之后的UIView的高度
4.9.2 例
UIView * adView = [self.adViewArr objectAtIndex:i];
NSLog(@"更新后 =============== %f",[[CPCCoreServer sharedInstance] cpcConfigWithFont:adView font:[UIFont systemFontOfSize:fontSize]]);
4.9.3 参数说明
参数 | 说明 |
---|---|
adView | 广告对象 |
font | 字体对象 |