MFAdBottomView 廣告說明文件
建立置底廣告物件
MFAdBottomView 提供簡單的初始化方式,可用於顯示 畫面底部的廣告。
初始化廣告物件
適用於 固定在畫面底部 的廣告顯示。
MFAdBottomView.init(bannerId: String)
bannerId: 版位 ID (String)
範例:
let adbottom = MFAdBottomView(bannerId: "21963")
廣告設定
設定除錯訊息
用於 開發階段的除錯資訊。
debugInfo(_ state: String)
state: 除錯訊息 ("info")
範例:
adbottom.debugInfo("info")
廣告操作
請求廣告並顯示
將廣告加入畫面並向伺服器請求廣告。
requestAd()
範例:
self.view.addSubview(adbottom)
adbottom.requestAd()
顯示廣告
成功請求廣告後,顯示置底廣告。
show()
範例:
adbottom.show()
移除廣告
停止廣告顯示並釋放資源。
releseAD()
範例:
adbottom.releseAD()
MFAdBottomViewDelegate 事件
成功請求廣告
當廣告請求成功時觸發。
func requestAdSuccess()
範例:
func requestAdSuccess() {
adbottom.show()
print("成功請求廣告")
}
廣告請求失敗
當廣告請求失敗時觸發。
func requestAdFail()
範例:
func requestAdFail() {
print("請求廣告失敗")
}
點擊廣告
當用戶點擊廣告時觸發。
func onClickAd(_ message: String)
範例:
func onClickAd(_ urlStr: String) {
print("點擊廣告 URL: \(urlStr)")
if let url = URL(string: urlStr) {
let path = url.path
print(path)
}
}
廣告關閉事件
當用戶關閉廣告時觸發。
func onCloseAd()
範例:
func onCloseAd() {
print("關閉廣告")
}