목차
Table of Contents |
---|
minLevel | 1 |
---|
maxLevel | 1 |
---|
exclude | 목차 |
---|
|
개요
본 가이드는 Native 지면에서 추가적으로 제공하는 기능에 대하여 추가적으로 설명합니다. 필요에 따라 가이드를 참고하시어 더욱 고도화할 수 있습니다.
CTA(Call to action) 버튼 커스터마이징
...
BuzzAd iOS SDK 에서 제공하는 CTA 버튼의 UI 및 처리 로직을 사용하지 않고 구현할 수 있습니다. 버튼에 표기하는 문구는 사용자에게 광고 참여 상태를 알려야합니다. 다음과 같은 상황에 적절한 문구를 표기해야 사용자에게 생기는 오해를 방지할 수 있습니다.
...
Expand |
---|
|
Code Block |
---|
| - (void)updateCtaButtonWithAd:(BABAd *)ad {
NSString *callToAction = ad.creative.callToAction;
double reward = [ad.reward getAvailableReward];
double totalReward = [ad getTotalReward];
BOOL isParticipated = [ad isParticipated];
BOOL isClicked = [ad isClicked];
BOOL isActionType = [ad isActionType];
if (isClicked && isActionType && !isParticipated) {
_rewardIcon.image = nil;
_ctaLabel.text = @"참여 확인 중";
// LayoutConstraint 조정
...
} else {
if (totalReward > 0 && isParticipated) {
_rewardIcon.image = [UIImage imageNamed:@"ic_check"];
_ctaLabel.text = @"참여 완료";
// LayoutConstraint 조정
...
} else if (reward > 0) {
_rewardIcon.image = [UIImage imageNamed:@"ic_coin"];
_ctaLabel.text = [NSString stringWithFormat:@"+%d %@", (int)reward, callToAction];
// LayoutConstraint 조정
...
} else {
_rewardIcon.image = nil;
_ctaLabel.text = callToAction;
// LayoutConstraint 조정
...
}
}
}
#pragma mark - BABNativeAdViewDelegate
// 광고가 impress 되었을 때 호출됩니다.
- (void)BABNativeAdView:(BABNativeAdView *)adView didImpressAd:(BABAd *)ad {
}
// 광고가 click 되었을 때 호출됩니다.
- (void)BABNativeAdView:(BABNativeAdView *)adView didClickAd:(BABAd *)ad {
[self updateCtaButtonWithAd:ad];
}
// 리워드 요청이 시작될 때 호출됩니다.
- (void)BABNativeAdView:(BABNativeAdView *)adView willRequestRewardForAd:(BABAd *)ad {
[self updateCtaButtonWithAd:ad];
}
// 리워드 요청이 완료되었을 때 호출됩니다. 결과는 `result` 인자에 담겨있습니다.
- (void)BABNativeAdView:(BABNativeAdView *)adView didRewardForAd:(BABAd *)ad withResult:(BABRewardResult)result {
}
// 광고에 참여 완료 되었을 때 호출됩니다. 이곳에서 UI를 참여 완료 상태로 변경합니다.
- (void)BABNativeAdView:(BABNativeAdView *)adView didParticipateAd:(BABAd *)ad {
[self updateCtaButtonWithAd:ad];
} |
|
Expand |
---|
|
Code Block |
---|
| func updateCtaButton(ad: BABAd) {
let callToAction = ad.creative.callToAction ?? "디폴트 스트링"
let reward = ad.rewardgetAvailableReward()
let totalReward = ad.getTotalReward()
let isParticipated = ad.isParticipated()
let isClicked = ad.isClicked()
let isActionType = ad.isActionType()
if (isClicked && isActionType && !isParticipated) {
rewardIcon.image = nil
ctaLabel.text = "참여 확인 중"
// LayoutConstraint 조정
...
} else {
if (totalReward > 0 && isParticipated) {
rewardIcon.image = UIImage(named: "ic_check")
ctaLabel.text = "참여 완료"
// LayoutConstraint 조정
...
} else if (reward > 0) {
rewardIcon.image = UIImage(named: "ic_coin")
ctaLabel.text = "\(Int(ad.reward))P \(callToAction)"
// LayoutConstraint 조정
...
} else {
rewardIcon.image = nil
ctaLabel.text = callToAction
// LayoutConstraint 조정
...
}
}
}
// MARK: BABNativeAdViewDelegate
// 광고가 impress 되었을 때 호출됩니다.
func babNativeAdView(_ adView: BABNativeAdView, didImpress ad: BABAd) {
NSLog("Integration QA: ad impressed")
}
// 광고가 click 되었을 때 호출됩니다.
func babNativeAdView(_ adView: BABNativeAdView, didClick ad: BABAd) {
self.updateCtaButton(ad: ad);
NSLog("Integration QA: ad clicked")
}
// 리워드 요청이 시작될 때 호출됩니다.
func babNativeAdView(_ adView: BABNativeAdView, willRequestRewardFor ad: BABAd) {
self.updateCtaButton(ad: ad);
NSLog("Integration QA: will request reward for ad \(ad.creative.title!)")
}
// 리워드 요청이 완료되었을 때 호출됩니다. 결과는 `result` 인자에 담겨있습니다.
func babNativeAdView(_ adView: BABNativeAdView, didRewardFor ad: BABAd, with result: BABRewardResult) {
NSLog("Integration QA: reward request result \(result)")
}
// 광고에 참여 완료 되었을 때 호출됩니다. 이곳에서 UI를 참여 완료 상태로 변경합니다.
func babNativeAdView(_ adView: BABNativeAdView, didParticipateAd ad: BABAd) {
self.updateCtaButton(ad: ad);
// self.rewardIcon.image = UIImage(named: "ic_check")
NSLog("Integration QA: ad participated \(ad.creative.title!)")
} |
|
...
API | 설명 |
---|
totalReward
| 해당 광고에 할당된 총 리워드 양을 나타냅니다. 리워드 적립 주기가 지나지 않아 광고에 리워드가 할당되지 않는 경우에는 0으로 내려오게 됩니다. |
availableReward
| 해당 광고에 남아있는 총 리워드 양을 나타냅니다. 유저가 광고에서 특정 액션을 취하지 않아 받아가지 못한 리워드가 있을때 0보다 큰 값을 갖게됩니다. |
isParticipated
| 현재 할당 받은 광고들의 참여 상태를 sync하기 위한 값입니다. 광고 참여가 일어나면 해당 광고 및 메모리 상의 동일 광고들의 isParticipated값이 true로 바뀌며 onParticipate 콜백이 호출됩니다. |
isClicked
| 현재 할당 받은 광고의 클릭 여부를 나타내기 위한 값입니다. 광고를 클릭한 적이 있으면 true로 변경됩니다. 일부 액션형 광고의 경우 서버에서 참여 여부를 실시간으로 판단할 수 없습니다. 이 경우에는 isParticipated 값이 true가 아니므로, Click이 발생한 경우 “참여 확인 중” 이라는 CTA로 변경하여 유저 혼선을 줄일 수 있습니다. |
isActionType
| 참여형 광고의 경우 True 이며, 노출형 광고의 경우 False 입니다. |
한번에 여러 개의 광고 로드
WithSize
를 설정하여 loadAds
를 호출하면, 한 번의 광고 요청으로 여러 개의 광고를 할당받을 수 있습니다. 캐로셀형태와 같은 지면을 구현하는 경우 사용할 수 있습니다. 최대 10개까지 가능합니다.
...