CPCMobCPCDKTest is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'CPCMobCPCDK'
CPCMobCPCDKTest is available under the MIT license. See the LICENSE file for more info.
提供请求接口 ,通过广告位ID ,广告位类型 ,尺寸等 获取广告 SDK包含真机和模拟器两种架构
最低支持iOS 8.0 关闭 bitcode 添加 -ObjC
#3.0 暂无
+ (CPCCoreServer *)sharedInstance;
单例方式创建广告SDK对象
[CPCCoreServer sharedInstance]
- (BOOL)initWithCPCKey:(NSString *)patchKey;
初始化SDK ,并传如更新用的秘钥
[[CPCCoreServer sharedInstance] initWithCPCKey:@"XXXXXX"];
参数 | 说明 |
---|---|
patchKey | 秘钥 ,目前可随意传值 |
- (void)cpcGetADModel:(CPCAdViewConfig *)adviewConfig
success:(void (^)(CPCADViewConfigModel * adViewModel))success
failure:(void (^)(NSError * error))failure;
输入参数,并异步返回广告 model。
[[CPCCoreServer sharedInstance] getAdViewWithParameters:adBody delegate:self adViewSetting:setBody success:^(UIView *adView) {
} failure:^(NSError *error) {
}];
参数 | 说明 |
---|---|
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 | 左图还是右图(米读小说用) |
parameters字典 | 说明 |
---|---|
7277638 | 组图测试广告位 |
7479036 | 图文测试广告位 |
7112926 | 大图测试广告位 |
- (CGFloat)cpcAdViewForHeight:(CPCADViewConfigModel *)adViewModel;
根据物料model , 计算ADView的高度 , 如果不用这个方法, 用ADView.frame.size.height 同样可以获取高度
CGFloat adHeight = [[CPCCoreServer sharedInstance] adViewForHeight:adViewModel]
参数 | 说明 |
---|---|
adViewModel | 上一个方法请求回来的adViewmodeol物料 |
- (UIView *)cpcShowView:(CPCADViewConfigModel *)adViewModel
setDelegate:(id<CPCADViewDelegate>)delegate;
通过物料model获取广告view
UIView * adView = [[CPCCoreServer sharedInstance] cpcShowView:adViewModel setDelegate:self];
参数 | 说明 |
---|---|
adViewModel | getADModel方法请求回来的adViewmodeol物料 |
+ (void)setLogEnable:(BOOL)flag;
log 输出开关 , 默认关闭, YES开启
[CPCCoreServer setLogEnable:YES];
参数 | 说明 |
---|---|
flag | NO:关闭 YES:开启 |
- (void)cpcGetLaunchADView:(CPCLaunchAdViewConfig *)config
body:(NSDictionary *)parameters
window:(UIWindow *)window
success:(void (^)(NSObject * adViewModel))success
failure:(void (^)(NSError * error))failure;
传输请求参数 , 和配置参数 , 请求开屏 需要放到Appdelegate的 application:didFinishLaunchingWithOptions中 [self.window makeKeyAndVisible]后面
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) {
}];
/********************** 开屏广告 *****************/
参数 | 说明 |
---|---|
config | NO:关闭 YES:开启 |
parameters | 请求必要参数 |
window | 当前的window |
failure | 失败回调 |
- (CGFloat)cpcConfigWithFont:(UIView *)adView font:(UIFont*)font;
提供广告对象, 和font对象, 改变广告界面的字体 ,返回刷新之后的UIView的高度
UIView * adView = [self.adViewArr objectAtIndex:i];
NSLog(@"更新后 =============== %f",[[CPCCoreServer sharedInstance] cpcConfigWithFont:adView font:[UIFont systemFontOfSize:fontSize]]);
参数 | 说明 |
---|---|
adView | 广告对象 |
font | 字体对象 |