iOS: LevelPlay ad-unit bridge over SPM (LevelPlay-Swift-Package 9.6.1), ATT, consent
This commit is contained in:
parent
ca046c01bd
commit
7fe026fd4d
3 changed files with 473 additions and 0 deletions
20
CapacitorLevelplay.podspec
Normal file
20
CapacitorLevelplay.podspec
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
require 'json'
|
||||||
|
|
||||||
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
||||||
|
|
||||||
|
Pod::Spec.new do |s|
|
||||||
|
s.name = 'CapacitorLevelplay'
|
||||||
|
s.version = package['version']
|
||||||
|
s.summary = package['description']
|
||||||
|
s.license = package['license']
|
||||||
|
s.homepage = package['repository']['url']
|
||||||
|
s.author = package['author']
|
||||||
|
s.source = { :git => package['repository']['url'], :tag => 'v' + package['version'] }
|
||||||
|
s.source_files = 'ios/Sources/**/*.{swift,h,m}'
|
||||||
|
s.ios.deployment_target = '15.0'
|
||||||
|
s.dependency 'Capacitor'
|
||||||
|
s.dependency 'IronSourceSDK', '~> 9.6.1'
|
||||||
|
s.frameworks = 'AppTrackingTransparency'
|
||||||
|
s.swift_version = '5.9'
|
||||||
|
s.static_framework = true
|
||||||
|
end
|
||||||
33
Package.swift
Normal file
33
Package.swift
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
// swift-tools-version: 5.9
|
||||||
|
import PackageDescription
|
||||||
|
|
||||||
|
let package = Package(
|
||||||
|
name: "CapacitorLevelplay",
|
||||||
|
platforms: [.iOS(.v15)],
|
||||||
|
products: [
|
||||||
|
.library(
|
||||||
|
name: "CapacitorLevelplay",
|
||||||
|
targets: ["LevelPlayPlugin"])
|
||||||
|
],
|
||||||
|
dependencies: [
|
||||||
|
.package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "8.0.0"),
|
||||||
|
// Official Unity LevelPlay SDK (binary xcframework + Ad Quality), https://github.com/ironsource-mobile/LevelPlay-Swift-Package
|
||||||
|
.package(url: "https://github.com/ironsource-mobile/LevelPlay-Swift-Package.git", "9.6.1"..<"10.0.0")
|
||||||
|
],
|
||||||
|
targets: [
|
||||||
|
.target(
|
||||||
|
name: "LevelPlayPlugin",
|
||||||
|
dependencies: [
|
||||||
|
.product(name: "Capacitor", package: "capacitor-swift-pm"),
|
||||||
|
.product(name: "Cordova", package: "capacitor-swift-pm"),
|
||||||
|
.product(name: "UnityMediationSDK", package: "LevelPlay-Swift-Package")
|
||||||
|
],
|
||||||
|
path: "ios/Sources/LevelPlayPlugin",
|
||||||
|
linkerSettings: [
|
||||||
|
.linkedFramework("AppTrackingTransparency"),
|
||||||
|
.linkedFramework("WebKit"),
|
||||||
|
.linkedFramework("JavaScriptCore"),
|
||||||
|
.linkedLibrary("sqlite3")
|
||||||
|
])
|
||||||
|
]
|
||||||
|
)
|
||||||
420
ios/Sources/LevelPlayPlugin/LevelPlayPlugin.swift
Normal file
420
ios/Sources/LevelPlayPlugin/LevelPlayPlugin.swift
Normal file
|
|
@ -0,0 +1,420 @@
|
||||||
|
import AppTrackingTransparency
|
||||||
|
import Capacitor
|
||||||
|
import Foundation
|
||||||
|
import IronSource
|
||||||
|
|
||||||
|
/// Capacitor bridge for the Unity LevelPlay SDK (ad-unit API: `LPMRewardedAd` / `LPMInterstitialAd`).
|
||||||
|
/// Rewarded and interstitial only. All LevelPlay calls run on the main thread.
|
||||||
|
@objc(LevelPlayPlugin)
|
||||||
|
public class LevelPlayPlugin: CAPPlugin, CAPBridgedPlugin {
|
||||||
|
public let identifier = "LevelPlayPlugin"
|
||||||
|
public let jsName = "LevelPlay"
|
||||||
|
public let pluginMethods: [CAPPluginMethod] = [
|
||||||
|
CAPPluginMethod(name: "initialize", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "getSdkVersion", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "setConsent", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "setMetaData", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "requestTrackingAuthorization", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "getTrackingAuthorizationStatus", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "loadRewarded", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "showRewarded", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "loadInterstitial", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "showInterstitial", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "isReady", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "launchTestSuite", returnType: CAPPluginReturnPromise),
|
||||||
|
CAPPluginMethod(name: "validateIntegration", returnType: CAPPluginReturnPromise)
|
||||||
|
]
|
||||||
|
|
||||||
|
private enum InitState { case idle, running, done }
|
||||||
|
private var initState = InitState.idle
|
||||||
|
private var pendingInits: [CAPPluginCall] = []
|
||||||
|
private var rewarded: [String: RewardedHolder] = [:]
|
||||||
|
private var interstitials: [String: InterstitialHolder] = [:]
|
||||||
|
|
||||||
|
// MARK: - Init / settings
|
||||||
|
|
||||||
|
@objc func initialize(_ call: CAPPluginCall) {
|
||||||
|
guard let appKey = call.getString("appKey"), !appKey.isEmpty else {
|
||||||
|
call.reject("appKey is required", "INVALID_ARGUMENT")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
switch self.initState {
|
||||||
|
case .done:
|
||||||
|
call.resolve(["sdkVersion": LevelPlay.sdkVersion()])
|
||||||
|
return
|
||||||
|
case .running:
|
||||||
|
self.pendingInits.append(call)
|
||||||
|
return
|
||||||
|
case .idle:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
self.initState = .running
|
||||||
|
self.pendingInits.append(call)
|
||||||
|
if let consent = call.getObject("consent") { Self.applyConsent(consent) }
|
||||||
|
if call.getBool("testSuite") == true { LevelPlay.setMetaDataWithKey("is_test_suite", value: "enable") }
|
||||||
|
if call.getBool("adaptersDebug") == true { LevelPlay.setAdaptersDebug(true) }
|
||||||
|
var builder = LPMInitRequestBuilder(appKey: appKey)
|
||||||
|
if let userId = call.getString("userId"), !userId.isEmpty { builder = builder.withUserId(userId) }
|
||||||
|
LevelPlay.initWith(builder.build()) { _, error in
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
let calls = self.pendingInits
|
||||||
|
self.pendingInits.removeAll()
|
||||||
|
if let error = error {
|
||||||
|
self.initState = .idle
|
||||||
|
let nsError = error as NSError
|
||||||
|
calls.forEach { $0.reject(nsError.localizedDescription, String(nsError.code), error) }
|
||||||
|
} else {
|
||||||
|
self.initState = .done
|
||||||
|
calls.forEach { $0.resolve(["sdkVersion": LevelPlay.sdkVersion()]) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func getSdkVersion(_ call: CAPPluginCall) {
|
||||||
|
call.resolve(["sdkVersion": LevelPlay.sdkVersion()])
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func setConsent(_ call: CAPPluginCall) {
|
||||||
|
let options = call.options as? [String: Any] ?? [:]
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
Self.applyConsent(options)
|
||||||
|
call.resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func applyConsent(_ options: [String: Any]) {
|
||||||
|
if let gdpr = options["gdprConsent"] as? Bool { LPMPrivacySettings.setGDPRConsent(gdpr) }
|
||||||
|
if let ccpa = options["ccpaDoNotSell"] as? Bool { LPMPrivacySettings.setCCPA(ccpa) }
|
||||||
|
if let coppa = options["coppa"] as? Bool { LPMPrivacySettings.setCOPPA(coppa) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func setMetaData(_ call: CAPPluginCall) {
|
||||||
|
guard let key = call.getString("key"), let value = call.getString("value") else {
|
||||||
|
call.reject("key and value are required", "INVALID_ARGUMENT")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
LevelPlay.setMetaDataWithKey(key, value: value)
|
||||||
|
call.resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - App Tracking Transparency
|
||||||
|
|
||||||
|
@objc func requestTrackingAuthorization(_ call: CAPPluginCall) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
ATTrackingManager.requestTrackingAuthorization { status in
|
||||||
|
call.resolve(["status": Self.trackingName(status)])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func getTrackingAuthorizationStatus(_ call: CAPPluginCall) {
|
||||||
|
call.resolve(["status": Self.trackingName(ATTrackingManager.trackingAuthorizationStatus)])
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func trackingName(_ status: ATTrackingManager.AuthorizationStatus) -> String {
|
||||||
|
switch status {
|
||||||
|
case .authorized: return "authorized"
|
||||||
|
case .denied: return "denied"
|
||||||
|
case .restricted: return "restricted"
|
||||||
|
case .notDetermined: return "notDetermined"
|
||||||
|
@unknown default: return "unavailable"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Rewarded
|
||||||
|
|
||||||
|
@objc func loadRewarded(_ call: CAPPluginCall) {
|
||||||
|
guard let adUnitId = requireAdUnit(call) else { return }
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.rewardedHolder(adUnitId).ad.loadAd()
|
||||||
|
call.resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func showRewarded(_ call: CAPPluginCall) {
|
||||||
|
guard let adUnitId = requireAdUnit(call) else { return }
|
||||||
|
let placement = call.getString("placementName")
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
let holder = self.rewardedHolder(adUnitId)
|
||||||
|
guard holder.ad.isAdReady(), let presenter = self.presenter() else {
|
||||||
|
call.resolve(Self.notReady())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
holder.begin(call)
|
||||||
|
holder.ad.showAd(viewController: presenter, placementName: placement)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func rewardedHolder(_ adUnitId: String) -> RewardedHolder {
|
||||||
|
if let holder = rewarded[adUnitId] { return holder }
|
||||||
|
let holder = RewardedHolder(adUnitId: adUnitId, plugin: self)
|
||||||
|
rewarded[adUnitId] = holder
|
||||||
|
return holder
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Interstitial
|
||||||
|
|
||||||
|
@objc func loadInterstitial(_ call: CAPPluginCall) {
|
||||||
|
guard let adUnitId = requireAdUnit(call) else { return }
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.interstitialHolder(adUnitId).ad.loadAd()
|
||||||
|
call.resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func showInterstitial(_ call: CAPPluginCall) {
|
||||||
|
guard let adUnitId = requireAdUnit(call) else { return }
|
||||||
|
let placement = call.getString("placementName")
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
let holder = self.interstitialHolder(adUnitId)
|
||||||
|
guard holder.ad.isAdReady(), let presenter = self.presenter() else {
|
||||||
|
call.resolve(Self.notReady())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
holder.begin(call)
|
||||||
|
holder.ad.showAd(viewController: presenter, placementName: placement)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func interstitialHolder(_ adUnitId: String) -> InterstitialHolder {
|
||||||
|
if let holder = interstitials[adUnitId] { return holder }
|
||||||
|
let holder = InterstitialHolder(adUnitId: adUnitId, plugin: self)
|
||||||
|
interstitials[adUnitId] = holder
|
||||||
|
return holder
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Misc
|
||||||
|
|
||||||
|
@objc func isReady(_ call: CAPPluginCall) {
|
||||||
|
guard let adUnitId = requireAdUnit(call) else { return }
|
||||||
|
let format = call.getString("format") ?? "rewarded"
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
let ready = format == "interstitial"
|
||||||
|
? (self.interstitials[adUnitId]?.ad.isAdReady() ?? false)
|
||||||
|
: (self.rewarded[adUnitId]?.ad.isAdReady() ?? false)
|
||||||
|
call.resolve(["ready": ready])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func launchTestSuite(_ call: CAPPluginCall) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
guard let presenter = self.presenter() else {
|
||||||
|
call.reject("No view controller to present the test suite", "NO_VIEW_CONTROLLER")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
LevelPlay.launchTestSuite(presenter)
|
||||||
|
call.resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc func validateIntegration(_ call: CAPPluginCall) {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
LevelPlay.validateIntegration()
|
||||||
|
call.resolve()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Helpers (internal so the holders can use them)
|
||||||
|
|
||||||
|
private func requireAdUnit(_ call: CAPPluginCall) -> String? {
|
||||||
|
guard let adUnitId = call.getString("adUnitId"), !adUnitId.isEmpty else {
|
||||||
|
call.reject("adUnitId is required", "INVALID_ARGUMENT")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return adUnitId
|
||||||
|
}
|
||||||
|
|
||||||
|
private func presenter() -> UIViewController? {
|
||||||
|
var top = bridge?.viewController
|
||||||
|
while let presented = top?.presentedViewController { top = presented }
|
||||||
|
return top
|
||||||
|
}
|
||||||
|
|
||||||
|
private static func notReady() -> [String: Any] {
|
||||||
|
return ["shown": false, "rewarded": false, "error": ["code": -1, "message": "Ad not ready"]]
|
||||||
|
}
|
||||||
|
|
||||||
|
func emit(_ event: String, _ data: [String: Any]) {
|
||||||
|
notifyListeners(event, data: data)
|
||||||
|
}
|
||||||
|
|
||||||
|
static func info(_ adInfo: LPMAdInfo?) -> [String: Any] {
|
||||||
|
guard let i = adInfo else { return [:] }
|
||||||
|
var out: [String: Any] = ["adId": i.adId, "adUnitId": i.adUnitId, "adUnitName": i.adUnitName,
|
||||||
|
"adFormat": i.adFormat, "adNetwork": i.adNetwork, "instanceName": i.instanceName,
|
||||||
|
"instanceId": i.instanceId, "country": i.country, "auctionId": i.auctionId,
|
||||||
|
"precision": i.precision, "revenue": i.revenue.doubleValue]
|
||||||
|
if let placement = i.placementName { out["placementName"] = placement }
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
static func error(_ error: Error) -> [String: Any] {
|
||||||
|
let e = error as NSError
|
||||||
|
return ["code": e.code, "message": e.localizedDescription]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One `LPMRewardedAd` per ad unit plus the pending show call. The SDK holds its delegate weakly; the plugin keeps
|
||||||
|
/// the holder alive. Reward and close can arrive in either order, so the show call resolves on close, after a short
|
||||||
|
/// grace for a late reward.
|
||||||
|
final class RewardedHolder: NSObject, LPMRewardedAdDelegate {
|
||||||
|
let ad: LPMRewardedAd
|
||||||
|
private let adUnitId: String
|
||||||
|
private weak var plugin: LevelPlayPlugin?
|
||||||
|
private var call: CAPPluginCall?
|
||||||
|
private var shown = false
|
||||||
|
private var reward: LPMReward?
|
||||||
|
private var lastInfo: LPMAdInfo?
|
||||||
|
private var closed = false
|
||||||
|
|
||||||
|
init(adUnitId: String, plugin: LevelPlayPlugin) {
|
||||||
|
self.adUnitId = adUnitId
|
||||||
|
self.plugin = plugin
|
||||||
|
self.ad = LPMRewardedAd(adUnitId: adUnitId)
|
||||||
|
super.init()
|
||||||
|
ad.setDelegate(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
func begin(_ call: CAPPluginCall) {
|
||||||
|
self.call = call
|
||||||
|
shown = false
|
||||||
|
reward = nil
|
||||||
|
lastInfo = nil
|
||||||
|
closed = false
|
||||||
|
}
|
||||||
|
|
||||||
|
private func base(_ info: LPMAdInfo?) -> [String: Any] {
|
||||||
|
var data: [String: Any] = ["format": "rewarded", "adUnitId": adUnitId]
|
||||||
|
if info != nil { data["adInfo"] = LevelPlayPlugin.info(info) }
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
private func finish(error: Error? = nil) {
|
||||||
|
guard let call = call else { return }
|
||||||
|
self.call = nil
|
||||||
|
var result: [String: Any] = ["shown": shown, "rewarded": reward != nil]
|
||||||
|
if let r = reward { result["reward"] = ["name": r.name, "amount": r.amount] }
|
||||||
|
if let e = error { result["error"] = LevelPlayPlugin.error(e) }
|
||||||
|
if lastInfo != nil { result["adInfo"] = LevelPlayPlugin.info(lastInfo) }
|
||||||
|
call.resolve(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func didLoadAd(with adInfo: LPMAdInfo) { plugin?.emit("loaded", base(adInfo)) }
|
||||||
|
|
||||||
|
func didFailToLoadAd(withAdUnitId adUnitId: String, error: Error) {
|
||||||
|
var data = base(nil)
|
||||||
|
data["error"] = LevelPlayPlugin.error(error)
|
||||||
|
plugin?.emit("loadFailed", data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func didDisplayAd(with adInfo: LPMAdInfo) {
|
||||||
|
shown = true
|
||||||
|
lastInfo = adInfo
|
||||||
|
plugin?.emit("displayed", base(adInfo))
|
||||||
|
}
|
||||||
|
|
||||||
|
func didFailToDisplayAd(with adInfo: LPMAdInfo, error: Error) {
|
||||||
|
var data = base(adInfo)
|
||||||
|
data["error"] = LevelPlayPlugin.error(error)
|
||||||
|
plugin?.emit("displayFailed", data)
|
||||||
|
finish(error: error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func didClickAd(with adInfo: LPMAdInfo) { plugin?.emit("clicked", base(adInfo)) }
|
||||||
|
|
||||||
|
func didRewardAd(with adInfo: LPMAdInfo, reward: LPMReward) {
|
||||||
|
self.reward = reward
|
||||||
|
var data = base(adInfo)
|
||||||
|
data["reward"] = ["name": reward.name, "amount": reward.amount]
|
||||||
|
plugin?.emit("rewarded", data)
|
||||||
|
if closed { finish() }
|
||||||
|
}
|
||||||
|
|
||||||
|
func didCloseAd(with adInfo: LPMAdInfo) {
|
||||||
|
closed = true
|
||||||
|
lastInfo = adInfo
|
||||||
|
plugin?.emit("closed", base(adInfo))
|
||||||
|
if reward != nil {
|
||||||
|
finish()
|
||||||
|
} else {
|
||||||
|
// Some networks deliver the reward right after the close callback.
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { [weak self] in self?.finish() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func didChangeAdInfo(_ adInfo: LPMAdInfo) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
final class InterstitialHolder: NSObject, LPMInterstitialAdDelegate {
|
||||||
|
let ad: LPMInterstitialAd
|
||||||
|
private let adUnitId: String
|
||||||
|
private weak var plugin: LevelPlayPlugin?
|
||||||
|
private var call: CAPPluginCall?
|
||||||
|
private var shown = false
|
||||||
|
private var lastInfo: LPMAdInfo?
|
||||||
|
|
||||||
|
init(adUnitId: String, plugin: LevelPlayPlugin) {
|
||||||
|
self.adUnitId = adUnitId
|
||||||
|
self.plugin = plugin
|
||||||
|
self.ad = LPMInterstitialAd(adUnitId: adUnitId)
|
||||||
|
super.init()
|
||||||
|
ad.setDelegate(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
func begin(_ call: CAPPluginCall) {
|
||||||
|
self.call = call
|
||||||
|
shown = false
|
||||||
|
lastInfo = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
private func base(_ info: LPMAdInfo?) -> [String: Any] {
|
||||||
|
var data: [String: Any] = ["format": "interstitial", "adUnitId": adUnitId]
|
||||||
|
if info != nil { data["adInfo"] = LevelPlayPlugin.info(info) }
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
private func finish(error: Error? = nil) {
|
||||||
|
guard let call = call else { return }
|
||||||
|
self.call = nil
|
||||||
|
var result: [String: Any] = ["shown": shown, "rewarded": false]
|
||||||
|
if let e = error { result["error"] = LevelPlayPlugin.error(e) }
|
||||||
|
if lastInfo != nil { result["adInfo"] = LevelPlayPlugin.info(lastInfo) }
|
||||||
|
call.resolve(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
func didLoadAd(with adInfo: LPMAdInfo) { plugin?.emit("loaded", base(adInfo)) }
|
||||||
|
|
||||||
|
func didFailToLoadAd(withAdUnitId adUnitId: String, error: Error) {
|
||||||
|
var data = base(nil)
|
||||||
|
data["error"] = LevelPlayPlugin.error(error)
|
||||||
|
plugin?.emit("loadFailed", data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func didDisplayAd(with adInfo: LPMAdInfo) {
|
||||||
|
shown = true
|
||||||
|
lastInfo = adInfo
|
||||||
|
plugin?.emit("displayed", base(adInfo))
|
||||||
|
}
|
||||||
|
|
||||||
|
func didFailToDisplayAd(with adInfo: LPMAdInfo, error: Error) {
|
||||||
|
var data = base(adInfo)
|
||||||
|
data["error"] = LevelPlayPlugin.error(error)
|
||||||
|
plugin?.emit("displayFailed", data)
|
||||||
|
finish(error: error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func didClickAd(with adInfo: LPMAdInfo) { plugin?.emit("clicked", base(adInfo)) }
|
||||||
|
|
||||||
|
func didCloseAd(with adInfo: LPMAdInfo) {
|
||||||
|
lastInfo = adInfo
|
||||||
|
plugin?.emit("closed", base(adInfo))
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
|
||||||
|
func didChangeAdInfo(_ adInfo: LPMAdInfo) {}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue