夜间
模板信息流
*模板信息流回调说明
信息流广告代理分两个部分,分别是广告管理和广告
广告管理 :JuHeBaoFeedAdManager
//信息流广告加载成功
- (void)juHeBaoAdsManagerSuccessToLoad:(JuHeBaoFeedAdManager *_Nonnull)adsManager nativeAds:(NSArray<JuHeBaoFeedAd *> *_Nullable)nativeAdDataArray;
///信息流广告加载失败
- (void)juHeBaoAdsManager:(JuHeBaoFeedAdManager *_Nonnull)adsManager didFailWithError:(NSError *_Nullable)error;
广告 :JuHeBaoFeedAd
/// 广告显示了本机广告位时
- (void)juHeBaoAdDidBecomeVisible:(JuHeBaoFeedAd *_Nonnull)nativeAd;
/// 广告点击
- (void)juHeBaoAdDidClick:(JuHeBaoFeedAd *_Nonnull)nativeAd withView:(UIView *_Nullable)view;
/// 广告即将展示全屏页面
- (void)juHeBaoAdWillPresentFullScreenModal:(JuHeBaoFeedAd *_Nonnull)nativeAd;
/// 广告当另一个控制器关闭时调用此方法。
- (void)juHeBaoAdDidCloseOtherController:(JuHeBaoFeedAd *_Nonnull)nativeAd interactionType:(BQInteractionType)interactionType;
/// 广告渲染成功
- (void)juHeBaoAdExpressViewRenderSuccess:(JuHeBaoFeedAd *_Nonnull)nativeAd;
/// 广告渲染失败
- (void)juHeBaoAdExpressViewRenderFail:(JuHeBaoFeedAd *_Nonnull)nativeAd error:(NSError *_Nullable)error;
*Banner广告使用示例
广告加载
1.Objective-C
JuHeBaoFeedAdManager *adManager = [[JuHeBaoFeedAdManager alloc] init];
- (void)loadFeedAdManager {
adManager.slotID = @"";
adManager.delegate = self;
adManager.adSize = CGSizeMake(375, 150);
[adManager loadJuHeBaoAdData:self];
}
- (void)juHeBaoAdsManagerSuccessToLoad:(JuHeBaoFeedAdManager *)adsManager nativeAds:(NSArray<JuHeBaoFeedAd *> *)nativeAdDataArray {
if (nativeAdDataArray.count > 0) {
for (JuHeBaoFeedAd *model in nativeAdDataArray) {
NSUInteger index = arc4random_uniform((int32_t)(dataSource.count - 2)) + 2;
model.rootViewController = self;
model.delegate = self;
[model render];
NSMutableArray *modelArray = [NSMutableArray arrayWithObject:model];
[dataSource insertObject:modelArray atIndex:index];
}
}
[tableView reloadData];
}
2.Swift
let adManager = JuHeBaoFeedAdManager()
func loadFeedAdManager(){
self.adManager.slotID = ""
self.adManager.delegate = self
self.adManager.adSize = CGSize(width: 375, height: 150)
self.adManager.loadJuHeBaoAdData(self)
}
func juHeBaoAdsManagerSuccess(toLoad adsManager: JuHeBaoFeedAdManager, nativeAds nativeAdDataArray: [JuHeBaoFeedAd]?) {
if let adDataArray = nativeAdDataArray {
for model in adDataArray {
let index = Int.random(in: 2..<(dataSource.count - 1))
model.rootViewController = self
model.delegate = self
model.render()
let modelArray = NSMutableArray(object: model)
dataSource.insert(modelArray, at: index)
}
}
tableView.reloadData()
}
广告展示
1.Objective-C
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! FeedViewCell
cell.label.text = "Cell\(dataSource[indexPath.row])"
let ad = dataSource[indexPath.row]
if !(ad is String) {
let nad = ad as! [JuHeBaoFeedAd]
if nad[0].adView != nil {
cell.contentView.addSubview(nad[0].adView!)
}
}
return cell
}
2.Swift
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! FeedViewCell
cell.label.text = "Cell\(dataSource[indexPath.row])"
let ad = dataSource[indexPath.row]
if !(ad is String) {
let nad = ad as! [JuHeBaoFeedAd]
if nad[0].adView != nil {
cell.contentView.addSubview(nad[0].adView!)
}
}
return cell
}