피드 광고 데이터를 조회해 직접 UI를 구성하여 광고를 송출합니다.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val webView = findViewById<WebView>(R.id.wvWebView)
// Web SDK 연동하는 WebView 설정
webView.settings.apply {
javaScriptEnabled = true // 자바스크립트 활성화
domStorageEnabled = true // DOM 스토리지 활성화
}
// JavaScript Interface 추가
webView.addJavascriptInterface(
SPCWebView.SPCWebBridge(context = context, webView = webView),
SPCWebView.WEB_VIEW_BRIDGE
)
}
class webSDKTestViewController: ViewController {
var webView: WKWebView = WKWebView()
var pageUrl = "test.html"
override func viewDidLoad(){
super.viewDidLoad()
// 웹뷰에 Javascript Bridge 설정
let scriptMessageHandler = AvatyeWebSDKController(rootWebView: webView)
webView.configuration.userContentController.add(scriptMessageHandler, name: "AvatyeBridge_SPC")
// 웹뷰 Delegate 설정
webView.navigationDelegate = self
// 웹뷰를 뷰에 추가
view.addSubview(webView)
// 웹 페이지 로드
if let url = URL(string: pageUrl) {
let request = URLRequest(url: url)
webView.load(request)
}
}
}
// WKWebview Delegate 구현
extension webSDKTestViewController: WKNavigationDelegate{
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
guard let url = navigationAction.request.url, url.absoluteString != "about:blank" else {
decisionHandler(.cancel)
return
}
if url.absoluteString != pageUrl {
// 웹뷰에서 사용중인 url과 다를 경우, 기본 브라우저로 오픈 처리
UIApplication.shared.open(url, options: [:]) { isSuccess in
// after open
}
decisionHandler(.cancel)
} else {
// 웹뷰 내에서 랜딩
decisionHandler(.allow)
}
}
}
<Html>
<Head>
</Head>
<body>
// 상용
<script src={'https://avatye-web-sdk.s3.ap-northeast-2.amazonaws.com/spc/pointhome-{version}.min.js'} />
// 테스트
<script src={'https://avatye-web-sdk.s3.ap-northeast-2.amazonaws.com/spc/pointhome-{version}-test.min.js'} />
</body>
</Html>
// 최초 initialize하여 광고 세팅에 필요한 데이터를 초기화합니다.
// Promise로 동작하며, init 이후에 바로 피드 광고를 조회할 경우 비동기 처리가 필요합니다.
Pointhome.feed.init({
uniqueID: '11111111-2222-3333-4444-555555555555', // user key
});
// (Sample) 피드 광고를 조회합니다.
const getFeed = async () => {
const result = await Pointhome.feed.get({
placementID: '', // 아래 표를 참고해 주세요.
targetFill: 10, // 불러올 광고 갯수
cursor: '', // 요청할 광고에서 제외할 광고 데이터
});
console.log(result);
// {
// cursor: 'bzc_gaot8Uq0T2odG6S_l3sCc875XP826CeoCvOvLPG0-Fj34YcI_8uLZab9NNSPaSzDjkVs3qgjhgt7iHCF9HX6l5WGqVPTU7-6s9p2J_wSvWlejrIVCzzpRiExKqoFxVKe6ahykOzv6aRMkf-SpbtC_s4fLfs4jNGg9uDpoZiLet5owqb77bdr9_ErzBf-NVsX0WVFx0p9zfkLOS8-wX6jrok-CwV6HXfcFmH5d7pFvr0=',
// items: [
// {
// id: 1999189,
// name: 'ALL',
// impression_urls: [
// 'https://atr.buzzvil.com/api/impression?data=Y4i8BXVAIbDvh3gHYfrRaFUuXUCWXYZGZ5P9WOofr2HgAUV1Xdxped01Su4et7zxSiE49BNJ1Nc3uFozzWjFM4cGbYZovt3zKxAgNlV6eJDwG1afbm0Lo_29H80JHqzl_L3HIynKbtb2rk9Nt4HwzhHpAyOQGD_gn02iUwnsww47Hx2gDwuUWQAfukJD5nHkaEFoNgNZT7WQdRCJ6ppF_Ny7peZHdT8byFwtY147awx7xoEb1Sn_3LPUu11vLTIy2Q9qSLcu7ovw1OcZYIDIVC129u0kL-HQ3Vm8FsXggJ84Il19M0pFe0Yh85Hylm-ti4w9kpZlpKRuruVM6zz6QTKdGxXYNwJk5MDcPQrJLvAG59JjUYw4pKzhksL4vAjUKGNQDuY-bAmUrMQy3uGHgUsFRSQpQ9hhSKnnx6yA7sKYwxIP07V6q9I2P1l6yrJL7VVQ4Dqajir0hrLgTy-QBnM_Y1hYK31mbBQ4rDxTZEYpZjMCUKSMbpqSlHpsIoFiscDFLIqPOM_qn3RgdTs_R-i-dOmHaWAdwm4K3bxHNXWzCGWJ7FqLpbpYK8E-pRltmYi41mm2FMaXs9eGgBRQY9UG6PurE1m87mIxF9ESAJ6uMqIbtQu8D9CD08hLH4C59a89IFY8lwGIVBvqIXom_JC-8KVXkds47OFYB_RuXP0znxxzQU1PQMrx6mR5ZlgxV7mR2rv8b8LTZrrzRl2Y7UO-TOQewVkY003HvhbcQw9bjn6D3iBHKp18KBsKkTZxo5t-8Noh4RF-8o6bSVJ7NyqHCSAk4rWrqa0J1V5R9UuISjKtcGZG1rp8uidn9kVdauswfUiXhMHr6I6xJoHQhHJRLHpA-9n0PxLK4uZcWyw%3D&ifv=__ifv__&position=__position__&session_id=__session_id__',
// ],
// reward: 4,
// reward_condition: 'click',
// check_participation_url: '',
// type: 'cpc',
// creative: {
// title: 'ALL_DEV_TEST10_CPC_creative_1',
// description:
// '임의의 포털 사이트로 랜딩되는 테스트 CPC 광고입니다.',
// click_url:
// 'https://screen.buzzvil.com/api/s2s/click_redirect/?payload=fUUPRSkJ9NE9o7ByhMhZQv5SRkyhkCJc2LkFS0NWcCp8mHLTsOV6z2Zj_KEDXXyMKxU5sdSCytoTP5Ghi3o_Ne6UjC9ZMWE_5MRBNVv-bNilmDgK2m5foWpehJBZbek7qM36U8b7VP-mCYfK5wRMWMFuuLHgD4q13R7aHzjVXYz-l6xathGYmacQTEuph0iMcL32fIeIO0Gc-KofjxVuii72n3pAwol-vscHf4TMiWz4chTILshR5NQJ51f2wzkymLTZGRSBvlhT_4mlT8e2CiQgk1ZB1YFQ3tM2gKUjFAIDU56n6gjd01Ywu1J5NuWEp4Lu4t8vddoisG7KuzSIQnfWTkIljrxH3JTQgO-wP82dnzz1H4pWAyJP6Dy3x1yYoVIGKGT1OjssiulC7ieepgNsaUQqtwE_b6NEF81PQQPiSsJkd2o4iFQLWWGpVbU9FTN0iIPUQyX2NU1oJ8FWv8_45LsiknU8U5dwUpJtxvxrs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4BzqywZLsiXyBa3TD3zvGuTJ3uk4ClQKp2wpf1rdLdQ1TyQhcDjjY94wuOUq5v8zopFCGA5P11OIrjhgovBhUGbBJGPko_3OMAcWKQU6v7W-21lGjrzotyHSka5e8yw-4_Uv59Ec76ZCwtjWXjDC4NvU--mla6VQAES3nA5oG8wcih3QWjADYvdADDGeIhfSBSCpaLNqmAYLWc6IK6SGFp01umfuvlHd3r8MQoHsnuo8RqILZbCZhQkXry5k%3D&custom=%7B%22id%22%3A1999189%2C%22appID%22%3A%22a66990f6144a46b9816de3283fd47083%22%2C%22userID%22%3A%229f7942e7077a4725982c087ed2d66958%22%2C%22env%22%3A%22DEV%22%7D',
// call_to_action: '자세히보기',
// width: 1200,
// height: 627,
// icon_url:
// 'https://d3aulf22blzf9p.cloudfront.net/uploads/1677233158-MPYED.png',
// image_url:
// 'https://d3aulf22blzf9p.cloudfront.net/uploads/1677233150-6CS5Z.jpg',
// is_deeplink: false,
// },
// payload: 'putqXcFNTNoLkOxbUqHJzEmWdsXV2V6KtVXFTwWmUtE=',
// },
// {
// id: 1999178,
// name: 'ALL',
// impression_urls: [
// 'https://atr.buzzvil.com/api/impression?data=Y4i8BXVAIbDvh3gHYfrRaFUuXUCWXYZGZ5P9WOofr2HgAUV1Xdxped01Su4et7zxBQDMIrDDN4DPdRvm-slq25v3n7DLo63ELE9UfAxL_v-8SiP0kVQdcVevMCY3J0wfWSV_BCvQ1neW69qQ5xbyF5ZRnaV4-_rkSc00cuA8FSYdxVExlPA92l8atteNS1vWQqAlygwHzU0wmP5nCSO0NhOsSYICIPurx-TmWVo-K5pFy6m65-u4iUud1BMq8ioOgsb81MnxydYluHl9Oc0BOpON8g6cedEmRtFBLudUzPqRgaC653GdP1ZQc3u-3QT51e9QCuHG9jjjt1IqNsvvOognv-NHcuy75INVUxt8GOFFS1JlfQxQcZOGB03JyEHFMGB7YM1o1yK-BDZFmBvSgqZft-YyDWe7Ik3nueyHmc1r6KyMv1-xpMOeCKakWbS_E8NDlWZdR9yGhT45Fl387gqNbdbDnppmTx-Aix_eWWI5aQy125YL7agJxufxjyOUGatAklR4oChHWzIYvMq3K4NEV274vO7i53C0elglztbuhmXhfNn1xm-pX3-HpFGHBmOOLx9jbBjKJhFThzJEFnqOdanWr-J_xK2knntoElwXTwf--f9Dd2iIX6YZ0ZvqYLfv3jbHiDLrB-3T6ZJaFuESiRBiWkIYlZAQXhomzfaN7n52rQWDIHaBnt929uaxpppUuinE0Pp1SD_Xtu1qix0XQ3OLF3ZhHIHxLGrgwqIzxyEkr3ZCG1_c7x-X8LR3aXSkDwo_4xKPxVEBcJ5fWrSeqgbMNCUDBGTF7RIcFh83RFuNt0-3Rx7gNTWFi1b1V0xRZIwbja3r9lNHjrAh9A%3D%3D&ifv=__ifv__&position=__position__&session_id=__session_id__',
// ],
// reward: 4,
// reward_condition: 'click',
// check_participation_url: '',
// type: 'cpm',
// creative: {
// title: 'ALL_DEV_TEST20_CPM_creative_1',
// description:
// '임의의 포털 사이트로 랜딩되는 테스트 CPM 광고입니다.',
// click_url:
// 'https://screen.buzzvil.com/api/s2s/click_redirect/?payload=fUUPRSkJ9NE9o7ByhMhZQv5SRkyhkCJc2LkFS0NWcCp8mHLTsOV6z2Zj_KEDXXyMKxU5sdSCytoTP5Ghi3o_NURJK95JJyhazIi_-6KZYL8FBD96EIfZhsJwqY2OkNObjqJhFMR8WLThC4Mk-KWea7g6h0TilGkGP7jC8WyiS6x3CAWbV6jmfcLWJ2P8FRz-zn9rXbf8xl1ya_nOORaV1dYmKx_b28AXcak5i0e0sD9KQ25TaCBuFiaAF1jlxmPj3qVK1Pejlaaxc1GY6b4LyKskgtL3tV4p2ZmYwi85BcPZEsWp4DWjjY8b1ozWRGcGyCwK6QssWHu4M0-4Bm3aU-RhGImdb2pxHSrOTVuS3PktH12GZJAfyYmZnlvfKeBlJ4v3Tpz8tgAzkfrJrUnoOJcozPgEqlMs22avRH891w-jH_TGzlyrvWJLQ_4hL4MZ0aSr1BNWwj4_iKqs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Q01is6i5YQCF1wC9Kq6ys8Ok7gyW10827tdPdYV4B7VxwF4pip3mHNFZXuAVTIVQ23SI-vGYyKyTp8blj7e51P9QZfIm2sIgQvdS16txTOAgUN42-79E5JRW8COU8EhKxywq11jHD7tulaPpB7JPCCej-HGLUUF8M27MfH8A14WsjMl8AqlbU0I5fUSSVExV5cClU6hjb__NnBZ-RzJVrv4O-Lv-Xf0LzfMCo38NucQD-a9HfgCNbpgo1g3T6K8XzQTojpkC2eong%3D%3D&custom=%7B%22id%22%3A1999178%2C%22appID%22%3A%22a66990f6144a46b9816de3283fd47083%22%2C%22userID%22%3A%229f7942e7077a4725982c087ed2d66958%22%2C%22env%22%3A%22DEV%22%7D',
// call_to_action: '자세히보기',
// width: 1200,
// height: 627,
// icon_url:
// 'https://d3aulf22blzf9p.cloudfront.net/uploads/1677232687-OWTLV.png',
// image_url:
// 'https://d3aulf22blzf9p.cloudfront.net/uploads/1677232676-B9IGL.jpg',
// is_deeplink: false,
// },
// payload: 'u5ggt09OYMVaDN51Mhb0JFG+1DXBVufkjfqIvl1P5sI=',
// },
// ],
// };
};
// 매출 정산을 위하여 광고 클릭 전에 호출 필요
// ex) impression_urls = ['https://...', 'https://...']
Pointhome.feed.impression(impression_urls);
광고 노출여부를 확인하기 위한 URL입니다.
매 광고마다 광고가 노출되었을 때, 해당 필드에 포함된 URL을 모두 호출해주세요.
광고 참여 URL입니다.
사용자가 광고를 클릭하는 경우, 해당 URL로 이동시켜주세요.
Pointhome Interface [@types/Pointhome.d.ts]
interface Pointhome {
NAM: {
init: ({ pubID, eventListener }: {
pubID: string;
eventListener?: {
onLoaded?: (elementID: string) => void;
onClicked?: (elementID: string) => void;
onError?: (elementID: string, stat: number) => void;
};
}) => Promise<void>;
setPlacements: (
params:
| {
elementID: string;
placementID: string;
adUnitID: string;
onClick: (elementID: string, curl: string) => void;
}
| {
elementID: string;
placementID: string;
adUnitID: string;
onClick: (elementID: string, curl: string) => void;
}[]
) => void;
};
feed: {
init: ({
uniqueID,
gender,
birthDate,
}: {
uniqueID: string;
gender?: string;
birthDate?: string;
}) => void;
get: ({
placementID,
targetFill,
cursor,
}: {
placementID: string;
targetFill?: string;
cursor?: string;
}) => Promise<Feed>;
};
};
type Feed = {
cursor: string;
items: {
id: string;
name: string;
impression_urls: string[];
reward: number;
reward_condition: string;
check_participation_url: string;
type: string;
payload: string;
creative: {
title: string;
description: string;
click_url: string;
call_to_action: string;
width: number;
height: number;
icon_url: string;
image_url: string;
is_deeplink: boolean;
};
}[];
}