请输入
菜单

集成与初始化

1. SDK下载

您可以从Hyperbid Tools SDK下载获取。

(1). 选择 SDK 版本

(2). 选择聚合平台

(3). 选择广告平台

(4). 点击生成接入代码(详见集成配置)

(5). 使用Cocoapods时,执行pod install --repo-update安装依赖

2. 初始化

2.1 创建MCInitConfig对象

objective-c 复制代码
// init SDK
MCInitConfig *config = [[MCInitConfig alloc] init];
config.appId = kMCSDKConfigInitAppId; //TopOn AppID
config.appKey = kMCSDKConfigInitAppKey; // TopOn Appkey
// config.defaultStrategyPath = [[NSBundle mainBundle] pathForResource:@"DefaultAppSettings" ofType:nil]; //本地默认预置策略文件路径
config.timeoutForUseDefaultStrategy = 0; //第一次请求线上策略时,等待多久使用本地默认预置策略,默认 0,不等待
// config.privacySettingsEnable = YES; //是否使用sdk内置的隐私流程
[[MCAPI sharedInstance] setMediationUpdateDelegate:self]; //设置代理

2.2 进行初始化

objective-c 复制代码
[[MCAPI sharedInstance] initWithConfig:config delegate:self]; //初始化多聚合SDK,传入第一步的config对象

2.3 接收初始化相关回调

objective-c 复制代码
- (void)didMediationInitFinished:(NSArray<NSNumber *> *)successMediationIdList failedError:(MCError *)failedError {
  // 初始化结果
  NSLog(@"MC --- init: %@, error: %@",successMediationIdList,failedError);
}


- (void)didMediationUpdated:(NSDictionary *)newAppSettings oldAppSettings:(NSDictionary *)oldAppSettings {
  NSLog(@"MC --- update new: %@, old: %@", newAppSettings, oldAppSettings);
}

2.4 示例代码

objective-c 复制代码
- (void)initMCSDK {
  [[MCAPI sharedInstance] setLogEnabled:YES];
  
  //自定义规则
  [MCAPI sharedInstance].customData = @{
    kMCCustomDataUserIDKey:@"test_custom_user_id"
  };
  
  //个性化
  [[MCAPI sharedInstance] setPersonalizedAdState:MCPersonalizedAdStateType];
  //gdpr
  [MCAPI sharedInstance].dataConsentSet = MCDataConsentSetNonpersonalized;
  //coppa
  [MCAPI sharedInstance].isAgeRestrictedUser = YES;
  //ccpa
  [MCAPI sharedInstance].doNotSell = YES;
  //静音
  [MCAPI sharedInstance].mute = YES;
  // 设置渠道
  [MCAPI sharedInstance].channel = @"channel";
  // 设置子渠道
  [MCAPI sharedInstance].subChannel = @"subChannel";
  
  // init SDK
  MCInitConfig *config = [[MCInitConfig alloc] init];
  config.appId = kMCSDKConfigInitAppId;
  config.appKey = kMCSDKConfigInitAppKey;
  // config.defaultStrategyPath = [[NSBundle mainBundle] pathForResource:@"DefaultAppSettings" ofType:nil];
  config.timeoutForUseDefaultStrategy = 0;
  // config.privacySettingsEnable = YES;
  [[MCAPI sharedInstance] setMediationUpdateDelegate:self];
  [[MCAPI sharedInstance] initWithConfig:config delegate:self];
}


- (void)didMediationInitFinished:(NSArray<NSNumber *> *)successMediationIdList failedError:(MCError *)failedError {
  // 初始化结果
  NSLog(@"MC --- init: %@, error: %@",successMediationIdList,failedError);
}


- (void)didMediationUpdated:(NSDictionary *)newAppSettings oldAppSettings:(NSDictionary *)oldAppSettings {
  NSLog(@"MC --- update new: %@, old: %@", newAppSettings, oldAppSettings);
}

2.5 MCDataConsentSet枚举

MCDataConsentSet 枚举值 说明
MCDataConsentSetUnknown 0 如果未设置,则默认为禁止数据同意
MCDataConsentSetPersonalized 1 同意
MCDataConsentSetNonpersonalized 2 禁止

2.6 MCPersonalizedAdState枚举

MCPersonalizedAdState 枚举值 说明
MCPersonalizedAdStateType 1 允许个性化
MCNonpersonalizedAdStateType 2 禁止个性化

3. 预置策略

建议配置预置策略,提高应用首次启动的广告加载效果。

上一个
iOS
下一个
广告样式
最近修改: 2025-09-08Powered by