101 lines
2.3 KiB
Swift
101 lines
2.3 KiB
Swift
//
|
|
// VPAdManager.swift
|
|
// Veloria
|
|
//
|
|
// Created by 湖南秦九 on 2025/7/14.
|
|
//
|
|
|
|
import UIKit
|
|
#if canImport(GoogleMobileAds)
|
|
import GoogleMobileAds
|
|
#endif
|
|
#if canImport(AppLovinSDK)
|
|
import AppLovinSDK
|
|
#endif
|
|
|
|
class VPAdManager: NSObject {
|
|
|
|
|
|
static var completer: (() -> Void)?
|
|
|
|
static func start() {
|
|
#if canImport(GoogleMobileAds)
|
|
MobileAds.shared.start()
|
|
#endif
|
|
|
|
initialize_applovinSdk()
|
|
}
|
|
|
|
///初始化AppLovinSDK
|
|
static func initialize_applovinSdk(completer: (() -> Void)? = nil) {
|
|
if completer != nil {
|
|
self.completer = completer
|
|
}
|
|
#if canImport(AppLovinSDK)
|
|
if !ALSdk.shared().isInitialized {
|
|
//初始化
|
|
let initConfig = ALSdkInitializationConfiguration(sdkKey: "XW2aulJv9urKD4MIIFT1xcSCuyTHaDZ9qUbDqygnTLS04GkdX7WMQJviGP5vDRWGsk4OJJIyLGRV3mbLqOWx0W") { builder in
|
|
builder.mediationProvider = ALMediationProviderMAX
|
|
//#if DEBUG
|
|
// builder.testDeviceAdvertisingIdentifiers = [JXUUID.idfa()]
|
|
//#endif
|
|
}
|
|
|
|
ALSdk.shared().initialize(with: initConfig) { sdkConfig in
|
|
// Start loading ads
|
|
self.completer?()
|
|
}
|
|
} else {
|
|
self.completer?()
|
|
}
|
|
#endif
|
|
}
|
|
|
|
}
|
|
|
|
//MARK: -------------- 单元ID --------------
|
|
extension VPAdManager {
|
|
|
|
///谷歌激励广告单元ID
|
|
static var google_rewardedAdUnitID: String {
|
|
#if DEBUG
|
|
return "ca-app-pub-3940256099942544/1712485313"
|
|
#else
|
|
return ""
|
|
#endif
|
|
}
|
|
|
|
///开屏广告的单元ID
|
|
static var google_appOpenAdUnitID: String {
|
|
#if DEBUG
|
|
return "ca-app-pub-3940256099942544/5575463023"
|
|
#else
|
|
return ""
|
|
#endif
|
|
}
|
|
///横幅广告单元ID
|
|
static var google_bannerAdUnitID: String {
|
|
#if DEBUG
|
|
return "ca-app-pub-3940256099942544/2435281174"
|
|
#else
|
|
return ""
|
|
#endif
|
|
}
|
|
|
|
///激励广告的单元ID
|
|
static var applovin_rewardedAdUnitID: String {
|
|
return "39bf981e27728eae"
|
|
}
|
|
|
|
///开屏广告的单元ID
|
|
static var applovin_appOpenAdUnitID: String {
|
|
return "d587df0fd75ff03b"
|
|
}
|
|
///横幅广告单元ID
|
|
static var applovin_bannerAdUnitID: String {
|
|
return "1eb6278843149711"
|
|
}
|
|
|
|
|
|
}
|