이 가이드는 iOS 앱 내의 WebView에서 광고를 표시하기 위한 BuzzAd-Benefit Web iOS용 SDK 연동 방법을 안내합니다.
BuzzAd Android SDK를 연동하려면 반드시 앱의 고유 식별자인 App ID
와 광고 지면의 고유 식별자 Unit ID
가 필요합니다. 연동용 ID를 발급받으려면 버즈빌 담당자에게 연락하세요.
ID 유형 | 설명 |
---|---|
App ID | BuzzAd Android용 SDK를 연동하는 앱 별로 부여하는 고유 식별자입니다. |
Unit ID | 앱 내에 광고 지면별로 부여하는 고유 식별자입니다. |
BuzzAd iOS용 SDK를 설치하려면 CocoaPods을 사용하여 Podfile
에 최신 버전의 BuzzAd SDK를 추가하세요.
pod 'BuzzAdBenefit', '= 3.31.1' |
최신 버전의 BuzzAd SDK를 확인하기 위해선 여기를 참고해 주세요. |
AppDelegate
의 application:didFinishLaunchingWithOptions
에서 [BuzzAdBenefit initializeWithConfig:]
를 호출해 BuzzAd iOS용 SDK를 초기화하세요.
@import BuzzAdBenefit; @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { BZVConfig *config = [BZVConfig configWithBlock:^(BZVConfigBuilder * _Nonnull builder) { builder.appId = @"YOUR_APP_ID"; }]; [BuzzAdBenefit initializeWithConfig:config]; return YES; } @end |
import BuzzAdBenefit @main final class AppDelegateSwift: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { let config = BZVConfig { builder in builder.appId = "YOUR_APP_ID" } BuzzAdBenefit.initialize(with: config) return true } |
광고 할당을 요청하려면 사용자 프로필을 등록해야 합니다. 사용자 프로필을 구성하는 항목은 아래 표를 참고하세요.
사용자 프로필 | 설명 | |
---|---|---|
| 매체사 앱에서 사용하는 사용자 식별자입니다. 서비스 도중 변하지 않는 고정 값이어야 하며, 광고 할당을 위해서 필수로 전달해야합니다.
| |
| 사용자의 성별입니다. 사용자 맞춤형 광고를 제공하는 데에 활용됩니다.
| |
| 사용자의 출생연도입니다. 사용자 맞춤형 광고를 제공하는 데에 활용됩니다. | |
| 사용자의 활동 추적 권한 획득 팝업 노출 여부입니다. 필수가 아닌 권장 등록 정보입니다. 자세한 정보는 iOS 14를 위한 대응 토픽을 참고하세요. |
다음은 SDK에 로그인을 요청하는 예시입니다. 로그인 상태를 확인하거나 로그아웃할 수도 있습니다.
// 로그인을 요청하는 코드입니다. [BuzzAdBenefit loginWithBlock:^(BZVLoginRequestBuilder * _Nonnull builder) { builder.userId = @"USER_ID"; builder.birthYear = YYYY; builder.gender = BZVUserGenderMale; // 남성 사용자 } onSuccess:^{ } onFailure:^(NSError * _Nonnull error) { }]; // 로그인 상태를 확인하는 코드입니다. [BuzzAdBenefit isLoggedIn]; // 로그아웃하는 코드입니다. [BuzzAdBenefit logout]; |
// 로그인을 요청하는 코드입니다. BuzzAdBenefit.login { builder in builder.userId = "USER_ID" builder.gender = .male // 남성 사용자 builder.birthYear = YYYY } onSuccess: { } onFailure: { error in } // 로그인 상태를 확인하는 코드입니다. BuzzAdBenefit.isLoggedIn() // 로그아웃하는 코드입니다. BuzzAdBenefit.logout() |
웹뷰 안에서 광고를 로드하려면 다음과 같이 웹뷰에 scriptMessageHandler
를 추가한 뒤 웹뷰로 넘어오는 scriptMessage를 BZVWebInterface
객체에게 전달해주어야 합니다.
- (void)viewDidLoad { [super viewDidLoad]; WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init]; WKUserContentController *contentController = [[WKUserContentController alloc] init]; [contentController addScriptMessageHandler:self name:BuzzAdBenefitWebInterfaceName]; config.userContentController = contentController; config.allowsInlineMediaPlayback = true; _webView = [[WKWebView alloc] initWithFrame:self.view.bounds configuration:config]; _webInterface = [[BZVWebInterface alloc] initWithWebView:_webView]; // 생략 ... } - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message { [_webInterface handleScriptMessage:message]; // 생략 ... } |
override func viewDidLoad() { super.viewDidLoad() let config = WKWebViewConfiguration() let contentController = WKUserContentController() contentController.add(self, name: BuzzAdBenefitWebInterfaceName) config.userContentController = contentController config.allowsInlineMediaPlayback = true webView = WKWebView(frame: self.view.bounds, configuration: config) webInterface = BZVWebInterface(webView: webView) // 생략 ... } func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) { webInterface.handleScriptMessage(message) // 생략 ... } |
BuzzAd iOS용 SDK를 사용하기 위한 모든 설정이 완료되었습니다. 앱을 빌드하고 정상적으로 실행되는지 확인하세요.
Github 샘플 코드를 통해 실제 구현에 사용된 예제를 참고할 수 있습니다.
Web SDK 연동 가이드를 참고하여 웹 페이지에 Web SDK를 추가하고, 앱에 광고 지면을 표시하세요.
사용자가 광고에 참여하면 포인트를 지급해야 하므로 포인트 적립 요청을 처리할 수 있는 서버가 필요합니다.
포인트 처리 서버를 준비하고, 포스트백 연동 가이드에 명시된 API 스펙에 따라 포스트백 API를 구현하세요.