102 lines
2.4 KiB
Swift
102 lines
2.4 KiB
Swift
//
|
|
// SRAdManger.swift
|
|
// SynthReel
|
|
//
|
|
// Created by 澜声世纪 on 2025/12/11.
|
|
// Copyright © 2025 SR. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
#if canImport(GoogleMobileAds)
|
|
import GoogleMobileAds
|
|
#endif
|
|
#if canImport(AppLovinSDK)
|
|
import AppLovinSDK
|
|
#endif
|
|
|
|
class SRAdManger: 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 SRAdManger {
|
|
|
|
///谷歌激励广告单元ID
|
|
static var google_rewardedAdUnitID: String {
|
|
#if DEBUG
|
|
return "ca-app-pub-3940256099942544/1712485313"
|
|
#else
|
|
return "ca-app-pub-6275401933109862/2121481439"
|
|
#endif
|
|
}
|
|
|
|
///开屏广告的单元ID
|
|
static var google_appOpenAdUnitID: String {
|
|
#if DEBUG
|
|
return "ca-app-pub-3940256099942544/5575463023"
|
|
#else
|
|
return "ca-app-pub-6275401933109862/7130265535"
|
|
#endif
|
|
}
|
|
///横幅广告单元ID
|
|
static var google_bannerAdUnitID: String {
|
|
#if DEBUG
|
|
return "ca-app-pub-3940256099942544/2435281174"
|
|
#else
|
|
return "ca-app-pub-6275401933109862/7971191024"
|
|
#endif
|
|
}
|
|
|
|
///激励广告的单元ID
|
|
static var applovin_rewardedAdUnitID: String {
|
|
return "3708ac6b6026e375"
|
|
}
|
|
|
|
// ///开屏广告的单元ID
|
|
// static var applovin_appOpenAdUnitID: String {
|
|
// return "d587df0fd75ff03b"
|
|
// }
|
|
// ///横幅广告单元ID
|
|
// static var applovin_bannerAdUnitID: String {
|
|
// return "1eb6278843149711"
|
|
// }
|
|
|
|
|
|
}
|