GetuiBXSdk
Demo工程。集成GetuiBXSdk: ipa增量约为500KB;
目前支持广告SDK:
广告SDK | 最低版本 | 单独集成的ipa增量 |
---|---|---|
穿山甲 | 3.3.1.5 | 2.5M |
广点通 | 4.11.12 | 2.6M |
百度联盟 | 4.73 | 0.7M |
变现猫 | 3.2.0 | 0.6M |
InMobi | 7.5.0 | 1.3M |
# Uncomment the next line to define a global platform for your project
platform :ios, '9.0'
target 'BXDemo' do
# Comment the next line if you don't want to use dynamic frameworks
# use_frameworks!
# 方式1:一键集成所有支持的广告平台(推荐)
pod "GetuiBXSDK"
# 方式2:挑选需要的广告平台
pod "GetuiBXSDK/csj"
pod "GetuiBXSDK/gdt"
pod "GetuiBXSDK/inmobi"
pod "GetuiBXSDK/bd"
pod "GetuiBXSDK/bxm"
# 方式3:自己指定广告平台SDK,可能存在兼容性问题
pod "GetuiBXSDK/core" #【必选】
pod 'Bytedance-UnionAD', '3.3.1.5' #使用自己指定的广告平台
pod "GDTMobSDK", '4.11.12' #使用自己指定的广告平台
pod "InMobiSDK-China", '7.5.0' #使用自己指定的广告平台
end
可用 "pod outdated" 命令查看是否有最新版本或者有依赖冲突导致不能升级到最新版本
在项目的Info.plist中添加 NSAllowsArbitraryLoads 禁用ATS限制。
GTBX_IOS_SDK/
|- readme.txt (SDK资料包说明)
|- document (SDK接入文档)
|- BXDemo-Pods (cocoapods集成demo)
|- BXDemo-Manual (手工集成demo)
|- GtBxSdkLib/ (sdk资料包)
| |- GetuiBXSdk.framework(个推变现SDK)
| |- Vendor/ (存放所有的第三方SDK依赖库。不需要集成的广告SDK请删除对应平台的文件、并在xcode工程中删除其引用)
| | |- libGTCommonSDK-1.1.1.0.a(个推基础库,集成多个个推sdk时,请保留一个最高版本的libGTCommonSDK即可)
使用SDK需添加依赖项:
AdSupport.framework
AVFoundation.framework
CoreLocation.framework
CoreTelephony.framework
CoreMotion.framework
MessageUI.framework
QuartzCore.framework
SafariServices.framework
Security.framework
SystemConfiguration.framework
WebKit.framework
CoreMedia.framework
libc++.tbd
libresolv.9.tbd
libsqlite3.tbd
libxml2.2.tbd
libz.1.1.3.tbd
BXDemo
工程,将GtBxSdkLib
添加到项目工程目录下:Move to Trash
彻底删除它GtBxSdkLib/Vendor
下已经不存在任何相关文件Framework Search Paths
和Library Search Paths
添加 "$(SRCROOT)/../GtBxSdkLib",并选择递归引入recursive
+ (void)startSdkWithKey:(GetuiBXSdkKey *)key delegate:(id<GetuiBXSdkDelegate>)delegate;
GetuiBXSdkDelegate
回调个推SDK初始化的错误信息以及第三方广告SDK的初始化错误信息。#import <GetuiBXSdk/GetuiBXSdk.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
GetuiBXSdkKey *key = [GetuiBXSdkKey new];
// 请修改成在 www.getui.com 上申请的 变现SDK信息
key.getui = @"请替换成 个推变现 的appid";
// 请修改成在 各家广告平台 上申请的 开发者信息
key.csj = @"请替换成 穿山甲 的appid";
key.gdt = @"请替换成 广点通 的appid";
key.bd = @"请替换成 百度联盟 的appid";
key.inmobi = @"请替换成 inmobi 的appid";
[GetuiBXSdk startSdkWithKey:key delegate:self];
return YES;
}
// SDK发生错误时将会回调错误信息
- (void)GetuiBXSdkDidOccurError:(NSError *)error {
/*
参数说明
error.code: 请看最后的常见错误码 GetuiBXSdkError 说明
41001 缺少Appid
*/
NSLog(@"GetuiBXSdkDidOccurError %@", error);
}
SDK启动后,将会打印当前第三方SDK集成情况信息:
GetuiBXSdk Info:
当前版本:BX-IOS-x.x.x.x
已集成SDK:
穿山甲-x.x.x.x
广点通-x.x.x
百度联盟-x.x
变现猫-x.x.x
InMobi-x.x.x
[GetuiBXSdk setDebug];
默认过期
,每次都会向服务端请求当前的广告位配置。 [GetuiBXSdk version];//BX-IOS-2.1.0.0
+ (void)setTags:(NSArray *)tags completion:(void (^)(BOOL isSuccess, NSError *error))completion;
NSArray *tags = @[@"001", @"002"];
[GetuiBXSdk setTags:tags completion:^(BOOL isSuccess, NSError *error) {
NSLog(@"setTags:%@ error:%@", isSuccess?@"成功":@"失败", error?:@"");
}];
- (instancetype)initWithAdId:(NSString *)adId
frame:(CGRect)frame
controller:(UIViewController *)controller
param:(GetuiBXParamObject *)param;
GetuiBXParamObject *param = [GetuiBXParamObject new];
[param timeout:5000];//设置超时时长
NSString *adId = kBanner;
if(self.banner) {
//移除Banner广告
[self.banner remove];
self.banner = nil;
}
self.banner = [[GetuiBXBanner alloc] initWithAdId:adId frame:CGRectMake(0, 100, [UIScreen mainScreen].bounds.size.width, 120) controller:self param:param];
self.banner.gtDelegate = self;
[self.banner loadAndShow:self.view];
- (void)GetuiBXComponentInitFail:(GetuiBXBanner *)component error:(NSError *)error {
// 组件加载失败
NSLog(@"demo-%s, error:%@", __FUNCTION__, error);
}
- (void)GetuiBXComponentAdFailShow:(GetuiBXBanner *)component error:(NSError *)error {
// 组件展示失败
NSLog(@"demo-%s, error:%@", __FUNCTION__, error);
}
- (void)GetuiBXComponentAdLoadSuccess:(GetuiBXBanner *)component {
// 组件加载成功
NSLog(@"demo-%s", __FUNCTION__);
}
- (void)GetuiBXComponentAdDidShow:(GetuiBXBanner *)component ad:(id)instance {
// 组件已展示
NSLog(@"demo-%s", __FUNCTION__);
}
- (void)GetuiBXComponentAdDidClick:(GetuiBXBanner *)component ad:(id)instance {
// 组件被点击
NSLog(@"demo-%s", __FUNCTION__);
}
- (void)GetuiBXComponentAdDidClose:(GetuiBXBanner *)component ad:(id)instance {
// 组件被关闭
NSLog(@"demo-%s", __FUNCTION__);
if (self.banner) {
//移除Banner广告
[self.banner remove];
}
}
- (void)GetuiBXComponentAdDidCloseDetail:(GetuiBXBanner *)component ad:(id)instance {
// 广告详情关闭
NSLog(@"demo-%s", __FUNCTION__);
}
-(void)GetuiBXComponentAdVideoFinish:(GetuiBXBanner *)component ad:(id)instance {
// 视频播放结束
NSLog(@"demo-%s", __FUNCTION__);
}
- (instancetype)initWithAdId:(NSString *)adId container:(UIWindow *)keyWindow param:(GetuiBXParamObject *)param;
GetuiBXParamObject *param = [GetuiBXParamObject new];
[param timeout:5000];
NSString *adId = kSplash;
self.splash = [[GetuiBXSplashAd alloc] initWithAdId:adId
container:UIApplication.sharedApplication.windows[0]
param:param];
self.splash.gtDelegate = self;
[self.splash loadAdData];
- (void)GetuiBXComponentAdLoadSuccess:(GetuiBXSplashAd *)component {
NSLog(@"demo-%s", __FUNCTION__);
//广告数据加载成功,展示开屏页
[self.splash showAd];
}
- (instancetype)initWithAdId:(NSString *)adId adSize:(CGSize)adSize params:(GetuiBXParamObject *)params;
GetuiBXParamObject *param = [GetuiBXParamObject new];
[param timeout:5000];
NSString *adId = kIntersitial;
self.ad = [[GetuiBXInterstitialAd alloc] initWithAdId:adId adSize:CGSizeMake(300, 450) params:[GetuiBXParamObject.alloc timeout:10000]];
self.ad.gtDelegate = self;
[self.ad loadAdData];
- (void)GetuiBXComponentAdLoadSuccess:(GetuiBXInterstitialAd *)component {
NSLog(@"demo-:%s", __FUNCTION__);
//广告数据加载成功,展示插屏
[self.ad showAdFromRootViewController:self];
}
- (instancetype)initWithAdId:(NSString *)adId params:(GetuiBXParamObject *)params;
GetuiBXParamObject *param = [GetuiBXParamObject new];
[param timeout:5000];
NSString *adId = kReward;
self.rewardVideoAd = [[GetuiBXRewardVideoAd alloc] initWithAdId:adId params:[[GetuiBXParamObject alloc] timeout:10000]];
self.rewardVideoAd.gtDelegate = (id) self;
[self.rewardVideoAd loadAdData];
- (void)GetuiBXComponentAdLoadSuccess:(GetuiBXRewardVideoAd *)component {
//激励视频广告数据加载完毕,展示激励视频
NSLog(@"demo-%s, 是否有效:%@", __FUNCTION__, @(self.rewardVideoAd.isAdValid));
[self.rewardVideoAd showAdWithController:self];
}
- (instancetype)initWithAdId:(NSString *)adId params:(GetuiBXNativeAdParams *)params;
//请求原生广告数据
CGSize size = CGSizeMake(BX_SCREEN_WIDTH, 338);
GetuiBXNativeAdParams *params = [[GetuiBXNativeAdParams alloc] timeout:10000];
params.viewController = self;
params.adSize = size;
self.nativeAd = [[GetuiBXNativeAd alloc] initWithAdId:adId params:params];
self.nativeAd.gtDelegate = self;
[self.nativeAd loadAdData];
- (void)GetuiBXComponentAdLoadSuccess:(GetuiBXNativeAd *)component {
//广告数据加载成功,获取广告view,渲染
NSLog(@"demo-%s", __FUNCTION__);
[self.expressAdViews addObjectsFromArray:self.nativeAd.adViews];
[self.expressAdViews enumerateObjectsUsingBlock:^(GetuiBXNativeAdView *expressView, NSUInteger idx, BOOL *_Nonnull stop) {
[expressView render];
}];
[self.tableView reloadData];
}
- (instancetype)initWithAdId:(NSString *)adId params:(GetuiBXNativeAdParams *)params;
GetuiBXNativeAd
- (instancetype)initWithAdId:(NSString *)adId
frame:(CGRect)frame
controller:(UIViewController *)controller
param:(GetuiBXParamObject *)param;
NSString *adId = kButton;
GetuiBXParamObject *param = [GetuiBXParamObject new];
[param timeout:5000];
GetuiBXButton *btn = [[GetuiBXButton alloc] initWithAdId:adId frame:CGRectMake(100, 150, 80, 80) controller:self param:param];
btn.gtDelegate = self;
[btn loadAdData];
self.btn = btn;
- (void)GetuiBXComponentAdLoadSuccess:(GetuiBXButton *)component {
//广告数据加载成功,展示按钮
NSLog(@"demo-%s", __FUNCTION__);
[self.btn showToView:self.view];
}
- (instancetype)initWithAdId:(NSString *)adId
frame:(CGRect)frame
controller:(UIViewController*)controller
param:(GetuiBXParamObject *)param;
NSString *adId = kFloat;
GetuiBXParamObject *param = [GetuiBXParamObject new];
[param timeout:5000];
GetuiBXFloat *floatAd = [[GetuiBXFloat alloc] initWithAdId:adId frame:CGRectMake(100, 150, 80, 80) controller:self param:param];
floatAd.gtDelegate = self;
[floatAd loadAdData];
self.floatAd = floatAd;
- (void)GetuiBXComponentAdLoadSuccess:(GetuiBXFloat *)component {
//广告数据加载成功,展示浮标
NSLog(@"demo-%s", __FUNCTION__);
[self.floatAd showToView:self.view];
}
- (instancetype)initWithAdId:(NSString *)adId
imageSize:(GetuiAdSize)imageSize
param:(GetuiBXParamObject *)param;
GetuiAdSize
枚举,广告图片尺寸 //初始化GetuiBXAdTouch
self.touch = [GetuiBXAdTouch new];
//初始化自渲染广告
NSString *adId = kCustom;
GetuiBXParamObject *param = [GetuiBXParamObject new];
[param timeout:5000];
GetuiBXAd *ad = [[GetuiBXAd alloc] initWithAdId:adId imageSize:GetuiAdSize_Banner600_388 param:param];
ad.gtDelegate = self;
// 广告数据一次最多获取3条
[ad loadAdWithCount:3];
self.ad = ad;
- (void)GetuiBXComponentAdLoadSuccess:(GetuiBXAd *)component {
//广告数据加载成功
NSLog(@"demo-%s", __FUNCTION__);
if (![component isKindOfClass:[GetuiBXAd class]]) {
return;
}
NSArray *adArray = component.list;
if (adArray.count > 0) {
GetuiBXAdObject *object = adArray[0];//获取广告数据实例
self.titleLabel.text = object.title;//设置UI
self.touch.gtDelegate = self;
//注册UI视图的点击事件
[self.touch registerData:object viewController:self clickableViews:@[self.adView]];
}
}
// 41000~接口调用错误
GetuiBXSdkErrorAppIdMissing = 41001, // 缺少Appid
// setTag接口错误码
GetuiBXSdkErrorTagLocal = 41101, // setTags本地校验错误
GetuiBXSdkErrorTagNetwork = 41102, // setTags网络错误
GetuiBXSdkErrorTagServer = 41103, // setTags服务端返回错误
// 42000~广告配置错误
GetuiBXSdkErrorAdConfig = 42001, // 获取广告配置失败
GetuiBXSdkErrorAdDailylimit = 42002, // 广告组当日超限
GetuiBXSdkErrorAdHourlylimit = 42003, // 广告组小时超限
// 43000~广告组件错误
GetuiBXSdkErrorLoadFailed = 43001, // 广告组件初始化失败
GetuiBXSdkErrorSDKLoadFailed = 43002, // 第三方SDK初始化失败
GetuiBXSdkErrorAdLoadFailed = 43003, // 广告数据加载失败
GetuiBXSdkErrorAdInvalid = 43004, // 广告无效
以上文档对您是否有帮助?