Veloria/Veloria/Libs/AdManager/VPAdManager.swift
2025-07-17 19:43:53 +08:00

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"
}
}