iOS 팝업 광고
Last updated
Last updated
팝업 지면은 전면광고와 유사하게 앱을 완전히 덮으면서 노출됩니다. 팝업 지면은 위치에 따라 하단, 중앙 두가지 타입의 UI를 제공하고 있어 원하는 기획에 맞게 선택하여 연동할 수 있습니다.
let popupAd = AdropPopupAd(unitId: "PUBLIC_TEST_UNIT_ID_POPUP_BOTTOM")
popupAd.delegate = self
popupAd.backgroundColor = your_color // optional UIColor
popupAd.hideForTodayTextColor = your_color // optional UIColor
popupAd.closeTextColor = your_color // optional UIColor
popupAd.delegate = self
popupAd.load()
...
// call show function when the ad needs to be displayed.
popupAd.show(fromRootViewController: viewController)
self.popupAd = [[AdropPopupAd alloc] initWithUnitId:@"PUBLIC_TEST_UNIT_ID_POPUP_BOTTOM"];
self.popupAd.delegate = self;
self.popupAd.backgroundColor = your_color; // optional UIColor
self.popupAd.hideForTodayTextColor = your_color; // optional UIColor
self.popupAd.closeTextColor = your_color; // optional UIColor
[self.popupAd load];
...
// call show function when the ad needs to be displayed.
[self.popupAd showFromRootViewController:self];
class AdropPopupAdWrapper: AdropPopupAdDelegate {
var popupAd: AdropPopupAd?
var errorHandler: (String) -> Void
init(_ unitId: String, handler: @escaping (_ error: String) -> Void) {
self.popupAd = AdropPopupAd(unitId: unitId)
self.errorHandler = handler
self.popupAd.backgroundColor = your_color; // optional UIColor
self.popupAd.hideForTodayTextColor = your_color; // optional UIColor
self.popupAd.closeTextColor = your_color; // optional UIColor
popupAd?.delegate = self
}
func onAdReceived(_ ad: AdropAds.AdropPopupAd) {
print("onAdReceived")
}
func onAdFailedToReceive(_ ad: AdropAds.AdropPopupAd, _ error: AdropAds.AdropErrorCode) {
print("onAdFailedToReceive \(AdropErrorCodeToString(code: error))")
self.errorHandler(AdropErrorCodeToString(code: error))
}
func load() {
popupAd?.delegate = self
popupAd?.load()
}
func show(fromRootViewController: UIViewController) {
popupAd?.show(fromRootViewController: fromRootViewController)
}
}
struct AdropPopupAdView: View {
@State var popupAdWrapper :AdropPopupAdWrapper? = nil
var body: some View {
NavigationView {
VStack {
Button {
popupAdWrapper = AdropPopupAdWrapper("PUBLIC_TEST_UNIT_ID_POPUP_BOTTOM") { _ in }
popupAdWrapper?.load()
} label: {
Text("load")
}
.padding(.all)
Button {
popupAdWrapper?.show(fromRootViewController: (UIApplication.shared.windows.first?.rootViewController)!)
} label: {
Text("show")
}
.padding(.all)
Spacer()
}
.navigationTitle("PopupAd Example")
}
}
}