修改b加入facebook
This commit is contained in:
parent
ba4491bbad
commit
bbe17724c1
2
Podfile
2
Podfile
@ -28,6 +28,8 @@ pod 'Firebase/Core'
|
|||||||
pod 'Firebase/AnalyticsWithoutAdIdSupport'
|
pod 'Firebase/AnalyticsWithoutAdIdSupport'
|
||||||
pod 'FirebaseRemoteConfig'
|
pod 'FirebaseRemoteConfig'
|
||||||
|
|
||||||
|
pod 'FBSDKCoreKit'
|
||||||
|
|
||||||
post_install do |installer|
|
post_install do |installer|
|
||||||
installer.generated_projects.each do |project|
|
installer.generated_projects.each do |project|
|
||||||
project.targets.each do |target|
|
project.targets.each do |target|
|
||||||
|
|||||||
@ -335,9 +335,9 @@
|
|||||||
75A3DFAB2C588772002AEACE /* LuxADManager */ = {
|
75A3DFAB2C588772002AEACE /* LuxADManager */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
755073C22C3F7FC200ADFD6B /* GoogleService-Info.plist */,
|
||||||
7559FE5B2C58C58D006A3D80 /* LuxADConfigure.h */,
|
7559FE5B2C58C58D006A3D80 /* LuxADConfigure.h */,
|
||||||
7559FE5C2C58C58D006A3D80 /* LuxADConfigure.m */,
|
7559FE5C2C58C58D006A3D80 /* LuxADConfigure.m */,
|
||||||
755073C22C3F7FC200ADFD6B /* GoogleService-Info.plist */,
|
|
||||||
75A3DFA12C588772002AEACE /* LuxADManager.h */,
|
75A3DFA12C588772002AEACE /* LuxADManager.h */,
|
||||||
75A3DFA22C588772002AEACE /* LuxADManager.m */,
|
75A3DFA22C588772002AEACE /* LuxADManager.m */,
|
||||||
75A3DFA32C588772002AEACE /* LuxADSSModeVC.h */,
|
75A3DFA32C588772002AEACE /* LuxADSSModeVC.h */,
|
||||||
@ -1050,7 +1050,7 @@
|
|||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
CODE_SIGN_ENTITLEMENTS = anniversary_Project/anniversary_Project.entitlements;
|
CODE_SIGN_ENTITLEMENTS = anniversary_Project/anniversary_Project.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 2;
|
CURRENT_PROJECT_VERSION = 3;
|
||||||
DEFINES_MODULE = YES;
|
DEFINES_MODULE = YES;
|
||||||
DEVELOPMENT_TEAM = MK2ZG9GGT4;
|
DEVELOPMENT_TEAM = MK2ZG9GGT4;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||||
@ -1104,7 +1104,7 @@
|
|||||||
"\"$(inherited) non-recursive\"",
|
"\"$(inherited) non-recursive\"",
|
||||||
);
|
);
|
||||||
INFOPLIST_FILE = anniversary_Project/Info.plist;
|
INFOPLIST_FILE = anniversary_Project/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = "Watermore\n";
|
INFOPLIST_KEY_CFBundleDisplayName = Watermore;
|
||||||
INFOPLIST_KEY_NSHealthShareUsageDescription = "When we record drinking water on the home page, we need to read your health data in order to analyze your drinking habits.";
|
INFOPLIST_KEY_NSHealthShareUsageDescription = "When we record drinking water on the home page, we need to read your health data in order to analyze your drinking habits.";
|
||||||
INFOPLIST_KEY_NSHealthUpdateUsageDescription = "When we record drinking water on the home page, we need to enter your health data to record your water intake";
|
INFOPLIST_KEY_NSHealthUpdateUsageDescription = "When we record drinking water on the home page, we need to enter your health data to record your water intake";
|
||||||
INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "We need to access your photo album so you can add reminders for anniversaries or birthdays";
|
INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "We need to access your photo album so you can add reminders for anniversaries or birthdays";
|
||||||
@ -1118,7 +1118,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 2.2;
|
MARKETING_VERSION = 2.3;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.countdown.day.daycount;
|
PRODUCT_BUNDLE_IDENTIFIER = com.countdown.day.daycount;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||||
@ -1145,7 +1145,7 @@
|
|||||||
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
|
||||||
CODE_SIGN_ENTITLEMENTS = anniversary_Project/anniversary_Project.entitlements;
|
CODE_SIGN_ENTITLEMENTS = anniversary_Project/anniversary_Project.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 2;
|
CURRENT_PROJECT_VERSION = 3;
|
||||||
DEFINES_MODULE = YES;
|
DEFINES_MODULE = YES;
|
||||||
DEVELOPMENT_TEAM = MK2ZG9GGT4;
|
DEVELOPMENT_TEAM = MK2ZG9GGT4;
|
||||||
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
ENABLE_USER_SCRIPT_SANDBOXING = NO;
|
||||||
@ -1153,7 +1153,7 @@
|
|||||||
GCC_PREFIX_HEADER = "/Users/yihai16/Documents/纳克斯/纪念日/anniversary_Project/anniversary_Project/anniversary_Project/header/anniversaryPCH.pch";
|
GCC_PREFIX_HEADER = "/Users/yihai16/Documents/纳克斯/纪念日/anniversary_Project/anniversary_Project/anniversary_Project/header/anniversaryPCH.pch";
|
||||||
GENERATE_INFOPLIST_FILE = YES;
|
GENERATE_INFOPLIST_FILE = YES;
|
||||||
INFOPLIST_FILE = anniversary_Project/Info.plist;
|
INFOPLIST_FILE = anniversary_Project/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = "Watermore\n";
|
INFOPLIST_KEY_CFBundleDisplayName = Watermore;
|
||||||
INFOPLIST_KEY_NSHealthShareUsageDescription = "When we record drinking water on the home page, we need to read your health data in order to analyze your drinking habits.";
|
INFOPLIST_KEY_NSHealthShareUsageDescription = "When we record drinking water on the home page, we need to read your health data in order to analyze your drinking habits.";
|
||||||
INFOPLIST_KEY_NSHealthUpdateUsageDescription = "When we record drinking water on the home page, we need to enter your health data to record your water intake";
|
INFOPLIST_KEY_NSHealthUpdateUsageDescription = "When we record drinking water on the home page, we need to enter your health data to record your water intake";
|
||||||
INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "We need to access your photo album so you can add reminders for anniversaries or birthdays";
|
INFOPLIST_KEY_NSPhotoLibraryUsageDescription = "We need to access your photo album so you can add reminders for anniversaries or birthdays";
|
||||||
@ -1167,7 +1167,7 @@
|
|||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
"@executable_path/Frameworks",
|
"@executable_path/Frameworks",
|
||||||
);
|
);
|
||||||
MARKETING_VERSION = 2.2;
|
MARKETING_VERSION = 2.3;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.countdown.day.daycount;
|
PRODUCT_BUNDLE_IDENTIFIER = com.countdown.day.daycount;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||||
|
|||||||
@ -10,8 +10,7 @@ import BRPickerView
|
|||||||
import Photos
|
import Photos
|
||||||
import SVProgressHUD
|
import SVProgressHUD
|
||||||
import WCDBSwift
|
import WCDBSwift
|
||||||
//import FirebaseAnalytics
|
|
||||||
import AppLovinSDK
|
|
||||||
import Alamofire
|
import Alamofire
|
||||||
import FirebaseRemoteConfig
|
import FirebaseRemoteConfig
|
||||||
|
|
||||||
@ -70,9 +69,6 @@ class AV_AddVC: AV_RootVC {
|
|||||||
|
|
||||||
var dataUpdateClosure: ((UserModel) -> Void)?
|
var dataUpdateClosure: ((UserModel) -> Void)?
|
||||||
|
|
||||||
var interstitialAd: MAInterstitialAd!
|
|
||||||
var remoteConfig: RemoteConfig!
|
|
||||||
var isadshow:Bool = false
|
|
||||||
var retryAttempt = 0.0
|
var retryAttempt = 0.0
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
@ -89,17 +85,7 @@ class AV_AddVC: AV_RootVC {
|
|||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
super.viewWillAppear(animated)
|
super.viewWillAppear(animated)
|
||||||
|
|
||||||
self.createInterstitialAd()
|
|
||||||
remoteConfig = RemoteConfig.remoteConfig()
|
|
||||||
|
|
||||||
// 设置最小获取间隔(开发期间可以设置较小的值)
|
|
||||||
let settings = RemoteConfigSettings()
|
|
||||||
settings.minimumFetchInterval = 0
|
|
||||||
remoteConfig.configSettings = settings
|
|
||||||
// Fetch 配置值
|
|
||||||
remoteConfig.setDefaults(fromPlist: "isopen")
|
|
||||||
fetchRemoteConfig()
|
|
||||||
|
|
||||||
|
|
||||||
if typeedit == 0{
|
if typeedit == 0{
|
||||||
@ -179,24 +165,10 @@ class AV_AddVC: AV_RootVC {
|
|||||||
DispatchQueue.global().asyncAfter(wallDeadline: .now() + 1.5) {
|
DispatchQueue.global().asyncAfter(wallDeadline: .now() + 1.5) {
|
||||||
SVProgressHUD.dismiss()
|
SVProgressHUD.dismiss()
|
||||||
}
|
}
|
||||||
if self.isadshow == true{
|
LuxADManager.shareInstance().showADByRandomMode(callback: {
|
||||||
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.5) {
|
actionType in
|
||||||
|
|
||||||
if self.interstitialAd.isReady {
|
|
||||||
self.interstitialAd.show()
|
|
||||||
self.setPostSHOW()
|
|
||||||
|
|
||||||
}else{
|
|
||||||
|
|
||||||
self.dismiss(animated: true)
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
|
|
||||||
self.dismiss(animated: true)
|
self.dismiss(animated: true)
|
||||||
|
})
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
let user = UserModel()
|
let user = UserModel()
|
||||||
@ -393,124 +365,6 @@ class AV_AddVC: AV_RootVC {
|
|||||||
self.deleteBtn.isHidden = true
|
self.deleteBtn.isHidden = true
|
||||||
}
|
}
|
||||||
|
|
||||||
///是否有广告
|
|
||||||
func fetchRemoteConfig() {
|
|
||||||
let localVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0"
|
|
||||||
remoteConfig.fetch{ (status, error) -> Void in
|
|
||||||
if status == .success {
|
|
||||||
print("Config fetched!")
|
|
||||||
self.remoteConfig.activate { changed, error in
|
|
||||||
if error == nil{
|
|
||||||
let js = self.remoteConfig.configValue(forKey: "isopen").jsonValue as! [String:Any]
|
|
||||||
let valueopen = js["isadopen"] as! Bool
|
|
||||||
let valueversion = js["version"] as! String
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
if valueversion == localVersion{
|
|
||||||
self.isadshow = false
|
|
||||||
}else{
|
|
||||||
if valueopen {
|
|
||||||
self.isadshow = true
|
|
||||||
} else {
|
|
||||||
self.isadshow = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
print("Config not fetched")
|
|
||||||
if let error = error {
|
|
||||||
print("Error: \(error.localizedDescription)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
func setPostload(){
|
|
||||||
let url = "http://111.9.47.226:38080/top_selection/save_ad_load_log"
|
|
||||||
let parameters:[String : Any] = [
|
|
||||||
"deviceId": StartManager.shared.devicID ?? "",
|
|
||||||
"localIp": StartManager.shared.localIP ?? "",
|
|
||||||
"remoteIp": StartManager.shared.publicIP ?? "",
|
|
||||||
"linkId": "",
|
|
||||||
"packageName": "com.countdown.day.daycount",
|
|
||||||
"gaid": StartManager.shared.idfaid ?? "",
|
|
||||||
"dataId": "",
|
|
||||||
"shelfNumber":"日历添加和返回",
|
|
||||||
"succeed": StartManager.shared.succeed,
|
|
||||||
"loadTime": "",
|
|
||||||
"adPlatform": StartManager.shared.adPlatform ?? "",
|
|
||||||
"countryCode": StartManager.shared.countryCode ?? "",
|
|
||||||
"adId": StartManager.shared.adId ?? "",
|
|
||||||
"platformResponseTime": StartManager.shared.platformResponseTime ?? "",
|
|
||||||
"getIpResponseTime": StartManager.shared.getIpResponseTime ?? "",
|
|
||||||
"ecpm": StartManager.shared.ecpm ?? "",
|
|
||||||
"dsp": StartManager.shared.dsp ?? "",
|
|
||||||
"network": StartManager.shared.network ?? "",
|
|
||||||
"showStatus": 0,
|
|
||||||
"washParam": true,
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
let headers: HTTPHeaders = [
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
]
|
|
||||||
|
|
||||||
NetworkManager.shared.postRequest(url: url, parameters: parameters, headers: headers) { result in
|
|
||||||
switch result {
|
|
||||||
case .success(let data):
|
|
||||||
print("Response:--- \(data)")
|
|
||||||
case .failure(let error):
|
|
||||||
print("Error:--- \(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func setPostSHOW(){
|
|
||||||
let url = "http://111.9.47.226:38080/top_selection/save_ad_show_log"
|
|
||||||
let parameters:[String : Any] = [
|
|
||||||
"deviceId": StartManager.shared.devicID ?? "",
|
|
||||||
"localIp": StartManager.shared.localIP ?? "",
|
|
||||||
"remoteIp": StartManager.shared.publicIP ?? "",
|
|
||||||
"linkId": "",
|
|
||||||
"packageName": "com.countdown.day.daycount",
|
|
||||||
"gaid": StartManager.shared.idfaid ?? "",
|
|
||||||
"dataId": "",
|
|
||||||
"shelfNumber":"日历添加和返回",
|
|
||||||
"succeed": StartManager.shared.succeed,
|
|
||||||
"loadTime": "",
|
|
||||||
"adPlatform": StartManager.shared.adPlatform ?? "",
|
|
||||||
"countryCode": StartManager.shared.countryCode ?? "",
|
|
||||||
"adId": StartManager.shared.adId ?? "",
|
|
||||||
"platformResponseTime": StartManager.shared.platformResponseTime ?? "",
|
|
||||||
"getIpResponseTime": StartManager.shared.getIpResponseTime ?? "",
|
|
||||||
"ecpm": StartManager.shared.ecpm ?? "",
|
|
||||||
"dsp": StartManager.shared.dsp ?? "",
|
|
||||||
"network": StartManager.shared.network ?? "",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
let headers: HTTPHeaders = [
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
]
|
|
||||||
|
|
||||||
NetworkManager.shared.postRequest(url: url, parameters: parameters, headers: headers) { result in
|
|
||||||
switch result {
|
|
||||||
case .success(let data):
|
|
||||||
print("Response:--- \(data)")
|
|
||||||
case .failure(let error):
|
|
||||||
print("Error:--- \(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,76 +400,4 @@ extension AV_AddVC:UIImagePickerControllerDelegate, UINavigationControllerDelega
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
extension AV_AddVC: MAAdDelegate
|
|
||||||
{
|
|
||||||
func createInterstitialAd()
|
|
||||||
{
|
|
||||||
|
|
||||||
let randomString = getRandomString()
|
|
||||||
interstitialAd = MAInterstitialAd(adUnitIdentifier: randomString ?? "8fccdfa964b52e26")
|
|
||||||
interstitialAd.delegate = self
|
|
||||||
|
|
||||||
// Load the first ad
|
|
||||||
interstitialAd.load()
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: MAAdDelegate Protocol
|
|
||||||
|
|
||||||
func didLoad(_ ad: MAAd)
|
|
||||||
{
|
|
||||||
// Interstitial ad is ready to be shown. 'interstitialAd.isReady' will now return 'true'
|
|
||||||
|
|
||||||
// Reset retry attempt
|
|
||||||
retryAttempt = 0
|
|
||||||
StartManager.shared.succeed = true
|
|
||||||
// StartManager.shared.loadTime = self.adLoadTime
|
|
||||||
StartManager.shared.adPlatform = "MAX"
|
|
||||||
StartManager.shared.countryCode = ALSdk.shared().configuration.countryCode
|
|
||||||
StartManager.shared.adId = "8fccdfa964b52e26"
|
|
||||||
StartManager.shared.platformResponseTime = ad.requestLatency
|
|
||||||
StartManager.shared.ecpm = Float(ad.revenue)
|
|
||||||
StartManager.shared.dsp = ad.dspName
|
|
||||||
StartManager.shared.network = ad.networkName
|
|
||||||
|
|
||||||
|
|
||||||
setPostload()
|
|
||||||
}
|
|
||||||
|
|
||||||
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError)
|
|
||||||
{
|
|
||||||
// Interstitial ad failed to load
|
|
||||||
// We recommend retrying with exponentially higher delays up to a maximum delay (in this case 64 seconds)
|
|
||||||
|
|
||||||
retryAttempt += 1
|
|
||||||
let delaySec = pow(2.0, min(6.0, retryAttempt))
|
|
||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + delaySec) {
|
|
||||||
self.interstitialAd.load()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func didDisplay(_ ad: MAAd)
|
|
||||||
{
|
|
||||||
// Pause your app's background audio
|
|
||||||
}
|
|
||||||
|
|
||||||
func didClick(_ ad: MAAd) {}
|
|
||||||
|
|
||||||
func didHide(_ ad: MAAd)
|
|
||||||
{
|
|
||||||
// Resume your app's background audio
|
|
||||||
// Interstitial ad is hidden. Pre-load the next ad
|
|
||||||
interstitialAd.load()
|
|
||||||
if self.typeedit == 0{
|
|
||||||
self.dismiss(animated: true)
|
|
||||||
}else{
|
|
||||||
self.navigationController?.popViewController(animated: true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func didFail(toDisplay ad: MAAd, withError error: MAError)
|
|
||||||
{
|
|
||||||
// Interstitial ad failed to display. We recommend loading the next ad
|
|
||||||
interstitialAd.load()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import AppLovinSDK
|
|||||||
import FirebaseCore
|
import FirebaseCore
|
||||||
import FirebaseAnalytics
|
import FirebaseAnalytics
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
import FBSDKCoreKit
|
||||||
|
|
||||||
@main
|
@main
|
||||||
class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDelegate {
|
class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDelegate {
|
||||||
@ -28,7 +29,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDe
|
|||||||
|
|
||||||
LuxADConfigure.shareInstance().checkATT()
|
LuxADConfigure.shareInstance().checkATT()
|
||||||
LuxADConfigure.shareInstance().configureADByFirebase(with: self.window!)
|
LuxADConfigure.shareInstance().configureADByFirebase(with: self.window!)
|
||||||
|
ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions)
|
||||||
setdispatch()
|
setdispatch()
|
||||||
stePermissions()
|
stePermissions()
|
||||||
|
|
||||||
@ -42,6 +43,14 @@ class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDe
|
|||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
func application(_ app: UIApplication,open url: URL,options:[UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
|
||||||
|
ApplicationDelegate.shared.application(
|
||||||
|
app,
|
||||||
|
open: url,
|
||||||
|
sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
|
||||||
|
annotation: options[UIApplication.OpenURLOptionsKey.annotation]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 当应用将要进入前台时调用(从后台到前台的过渡)
|
// 当应用将要进入前台时调用(从后台到前台的过渡)
|
||||||
|
|||||||
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import WCDBSwift
|
import WCDBSwift
|
||||||
import AppLovinSDK
|
|
||||||
import Alamofire
|
import Alamofire
|
||||||
import FirebaseRemoteConfig
|
import FirebaseRemoteConfig
|
||||||
|
|
||||||
@ -23,9 +22,7 @@ class AV_DetalisVC: AV_RootVC {
|
|||||||
|
|
||||||
@IBOutlet weak var bgView: UIView!
|
@IBOutlet weak var bgView: UIView!
|
||||||
|
|
||||||
var interstitialAd: MAInterstitialAd!
|
|
||||||
var remoteConfig: RemoteConfig!
|
|
||||||
var isadshow:Bool = false
|
|
||||||
var retryAttempt = 0.0
|
var retryAttempt = 0.0
|
||||||
|
|
||||||
var model:UserModel?
|
var model:UserModel?
|
||||||
@ -45,18 +42,7 @@ class AV_DetalisVC: AV_RootVC {
|
|||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
super.viewWillAppear(animated)
|
super.viewWillAppear(animated)
|
||||||
self.createInterstitialAd()
|
|
||||||
remoteConfig = RemoteConfig.remoteConfig()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 设置最小获取间隔(开发期间可以设置较小的值)
|
|
||||||
let settings = RemoteConfigSettings()
|
|
||||||
settings.minimumFetchInterval = 0
|
|
||||||
remoteConfig.configSettings = settings
|
|
||||||
// Fetch 配置值
|
|
||||||
remoteConfig.setDefaults(fromPlist: "isopen")
|
|
||||||
fetchRemoteConfig()
|
|
||||||
self.navigationController?.navigationBar.isHidden = true
|
self.navigationController?.navigationBar.isHidden = true
|
||||||
let image = model?.getImage()
|
let image = model?.getImage()
|
||||||
self.imageV.image = image
|
self.imageV.image = image
|
||||||
@ -87,39 +73,10 @@ class AV_DetalisVC: AV_RootVC {
|
|||||||
|
|
||||||
|
|
||||||
@IBAction func deleteBtn(_ sender: UIButton) {
|
@IBAction func deleteBtn(_ sender: UIButton) {
|
||||||
|
|
||||||
if self.isadshow == true{
|
|
||||||
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.5) {
|
|
||||||
|
|
||||||
if self.interstitialAd.isReady {
|
|
||||||
self.interstitialAd.show()
|
|
||||||
self.setPostSHOW()
|
|
||||||
if let uid = self.model?.uid {
|
|
||||||
// 构建删除条件
|
|
||||||
let condition: Condition = UserModel.Properties.uid == uid
|
|
||||||
|
|
||||||
// 调用删除方法
|
|
||||||
PrWCDBBaseManager.shared.deleteFromDb(fromTable: userModelTableName, where: condition)
|
|
||||||
} else {
|
|
||||||
print("Error: Model UID is nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
LuxADManager.shareInstance().showADByRandomMode(callback: {
|
||||||
if let uid = self.model?.uid {
|
actionType in
|
||||||
// 构建删除条件
|
if let uid = self.model?.uid {
|
||||||
let condition: Condition = UserModel.Properties.uid == uid
|
|
||||||
|
|
||||||
// 调用删除方法
|
|
||||||
PrWCDBBaseManager.shared.deleteFromDb(fromTable: userModelTableName, where: condition)
|
|
||||||
} else {
|
|
||||||
print("Error: Model UID is nil")
|
|
||||||
}
|
|
||||||
|
|
||||||
self.navigationController?.popViewController(animated: true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if let uid = model?.uid {
|
|
||||||
// 构建删除条件
|
// 构建删除条件
|
||||||
let condition: Condition = UserModel.Properties.uid == uid
|
let condition: Condition = UserModel.Properties.uid == uid
|
||||||
|
|
||||||
@ -128,215 +85,19 @@ class AV_DetalisVC: AV_RootVC {
|
|||||||
} else {
|
} else {
|
||||||
print("Error: Model UID is nil")
|
print("Error: Model UID is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
self.navigationController?.popViewController(animated: true)
|
self.navigationController?.popViewController(animated: true)
|
||||||
}
|
})
|
||||||
// navigationController?.popViewController(animated: true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@IBAction func back(_ sender: Any) {
|
@IBAction func back(_ sender: Any) {
|
||||||
if self.isadshow == true{
|
|
||||||
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.5) {
|
LuxADManager.shareInstance().showADByRandomMode(callback: {
|
||||||
|
actionType in
|
||||||
if self.interstitialAd.isReady {
|
|
||||||
self.interstitialAd.show()
|
|
||||||
self.setPostSHOW()
|
|
||||||
|
|
||||||
}else{
|
|
||||||
self.navigationController?.popViewController(animated: true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
self.navigationController?.popViewController(animated: true)
|
self.navigationController?.popViewController(animated: true)
|
||||||
}
|
})
|
||||||
}
|
|
||||||
///是否有广告
|
|
||||||
func fetchRemoteConfig() {
|
|
||||||
let localVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0"
|
|
||||||
remoteConfig.fetch{ (status, error) -> Void in
|
|
||||||
if status == .success {
|
|
||||||
print("Config fetched!")
|
|
||||||
self.remoteConfig.activate { changed, error in
|
|
||||||
if error == nil{
|
|
||||||
let js = self.remoteConfig.configValue(forKey: "isopen").jsonValue as! [String:Any]
|
|
||||||
let valueopen = js["isadopen"] as! Bool
|
|
||||||
let valueversion = js["version"] as! String
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
if valueversion == localVersion{
|
|
||||||
self.isadshow = false
|
|
||||||
}else{
|
|
||||||
if valueopen {
|
|
||||||
self.isadshow = true
|
|
||||||
} else {
|
|
||||||
self.isadshow = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
print("Config not fetched")
|
|
||||||
if let error = error {
|
|
||||||
print("Error: \(error.localizedDescription)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
func setPostload(){
|
|
||||||
let url = "http://111.9.47.226:38080/top_selection/save_ad_load_log"
|
|
||||||
let parameters:[String : Any] = [
|
|
||||||
"deviceId": StartManager.shared.devicID ?? "",
|
|
||||||
"localIp": StartManager.shared.localIP ?? "",
|
|
||||||
"remoteIp": StartManager.shared.publicIP ?? "",
|
|
||||||
"linkId": "",
|
|
||||||
"packageName": "com.countdown.day.daycount",
|
|
||||||
"gaid": StartManager.shared.idfaid ?? "",
|
|
||||||
"dataId": "",
|
|
||||||
"shelfNumber":"日程详情",
|
|
||||||
"succeed": StartManager.shared.succeed,
|
|
||||||
"loadTime": "",
|
|
||||||
"adPlatform": StartManager.shared.adPlatform ?? "",
|
|
||||||
"countryCode": StartManager.shared.countryCode ?? "",
|
|
||||||
"adId": StartManager.shared.adId ?? "",
|
|
||||||
"platformResponseTime": StartManager.shared.platformResponseTime ?? "",
|
|
||||||
"getIpResponseTime": StartManager.shared.getIpResponseTime ?? "",
|
|
||||||
"ecpm": StartManager.shared.ecpm ?? "",
|
|
||||||
"dsp": StartManager.shared.dsp ?? "",
|
|
||||||
"network": StartManager.shared.network ?? "",
|
|
||||||
"showStatus": 0,
|
|
||||||
"washParam": true,
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
let headers: HTTPHeaders = [
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
]
|
|
||||||
|
|
||||||
NetworkManager.shared.postRequest(url: url, parameters: parameters, headers: headers) { result in
|
|
||||||
switch result {
|
|
||||||
case .success(let data):
|
|
||||||
print("Response:--- \(data)")
|
|
||||||
case .failure(let error):
|
|
||||||
print("Error:--- \(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func setPostSHOW(){
|
|
||||||
let url = "http://111.9.47.226:38080/top_selection/save_ad_show_log"
|
|
||||||
let parameters:[String : Any] = [
|
|
||||||
"deviceId": StartManager.shared.devicID ?? "",
|
|
||||||
"localIp": StartManager.shared.localIP ?? "",
|
|
||||||
"remoteIp": StartManager.shared.publicIP ?? "",
|
|
||||||
"linkId": "",
|
|
||||||
"packageName": "com.countdown.day.daycount",
|
|
||||||
"gaid": StartManager.shared.idfaid ?? "",
|
|
||||||
"dataId": "",
|
|
||||||
"shelfNumber":"日程详情",
|
|
||||||
"succeed": StartManager.shared.succeed,
|
|
||||||
"loadTime": "",
|
|
||||||
"adPlatform": StartManager.shared.adPlatform ?? "",
|
|
||||||
"countryCode": StartManager.shared.countryCode ?? "",
|
|
||||||
"adId": StartManager.shared.adId ?? "",
|
|
||||||
"platformResponseTime": StartManager.shared.platformResponseTime ?? "",
|
|
||||||
"getIpResponseTime": StartManager.shared.getIpResponseTime ?? "",
|
|
||||||
"ecpm": StartManager.shared.ecpm ?? "",
|
|
||||||
"dsp": StartManager.shared.dsp ?? "",
|
|
||||||
"network": StartManager.shared.network ?? "",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
let headers: HTTPHeaders = [
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
]
|
|
||||||
|
|
||||||
NetworkManager.shared.postRequest(url: url, parameters: parameters, headers: headers) { result in
|
|
||||||
switch result {
|
|
||||||
case .success(let data):
|
|
||||||
print("Response:--- \(data)")
|
|
||||||
case .failure(let error):
|
|
||||||
print("Error:--- \(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
extension AV_DetalisVC: MAAdDelegate
|
|
||||||
{
|
|
||||||
func createInterstitialAd()
|
|
||||||
{
|
|
||||||
let randomString = getRandomString()
|
|
||||||
interstitialAd = MAInterstitialAd(adUnitIdentifier: randomString ?? "7baed02646413e44")
|
|
||||||
interstitialAd.delegate = self
|
|
||||||
|
|
||||||
// Load the first ad
|
|
||||||
interstitialAd.load()
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: MAAdDelegate Protocol
|
|
||||||
|
|
||||||
func didLoad(_ ad: MAAd)
|
|
||||||
{
|
|
||||||
// Interstitial ad is ready to be shown. 'interstitialAd.isReady' will now return 'true'
|
|
||||||
|
|
||||||
// Reset retry attempt
|
|
||||||
retryAttempt = 0
|
|
||||||
StartManager.shared.succeed = true
|
|
||||||
// StartManager.shared.loadTime = self.adLoadTime
|
|
||||||
StartManager.shared.adPlatform = "MAX"
|
|
||||||
StartManager.shared.countryCode = ALSdk.shared().configuration.countryCode
|
|
||||||
StartManager.shared.adId = "7baed02646413e44"
|
|
||||||
StartManager.shared.platformResponseTime = ad.requestLatency
|
|
||||||
StartManager.shared.ecpm = Float(ad.revenue)
|
|
||||||
StartManager.shared.dsp = ad.dspName
|
|
||||||
StartManager.shared.network = ad.networkName
|
|
||||||
|
|
||||||
|
|
||||||
setPostload()
|
|
||||||
}
|
|
||||||
|
|
||||||
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError)
|
|
||||||
{
|
|
||||||
// Interstitial ad failed to load
|
|
||||||
// We recommend retrying with exponentially higher delays up to a maximum delay (in this case 64 seconds)
|
|
||||||
|
|
||||||
retryAttempt += 1
|
|
||||||
let delaySec = pow(2.0, min(6.0, retryAttempt))
|
|
||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + delaySec) {
|
|
||||||
self.interstitialAd.load()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func didDisplay(_ ad: MAAd)
|
|
||||||
{
|
|
||||||
// Pause your app's background audio
|
|
||||||
}
|
|
||||||
|
|
||||||
func didClick(_ ad: MAAd) {}
|
|
||||||
|
|
||||||
func didHide(_ ad: MAAd)
|
|
||||||
{
|
|
||||||
// Resume your app's background audio
|
|
||||||
// Interstitial ad is hidden. Pre-load the next ad
|
|
||||||
interstitialAd.load()
|
|
||||||
|
|
||||||
self.navigationController?.popViewController(animated: true)
|
|
||||||
}
|
|
||||||
|
|
||||||
func didFail(toDisplay ad: MAAd, withError error: MAError)
|
|
||||||
{
|
|
||||||
// Interstitial ad failed to display. We recommend loading the next ad
|
|
||||||
interstitialAd.load()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -43,9 +43,6 @@ class AV_AddWaterVC: AV_RootVC {
|
|||||||
var bottomConstraint: NSLayoutConstraint?
|
var bottomConstraint: NSLayoutConstraint?
|
||||||
|
|
||||||
|
|
||||||
var interstitialAd: MAInterstitialAd!
|
|
||||||
var remoteConfig: RemoteConfig!
|
|
||||||
var isadshow:Bool = false
|
|
||||||
var retryAttempt = 0.0
|
var retryAttempt = 0.0
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
@ -95,26 +92,13 @@ class AV_AddWaterVC: AV_RootVC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func keyBoard(_ sender: Any) {
|
@IBAction func keyBoard(_ sender: Any) {
|
||||||
if self.isadshow == true{
|
|
||||||
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.5) {
|
LuxADManager.shareInstance().showADByRandomMode(callback: {
|
||||||
|
actionType in
|
||||||
if self.interstitialAd.isReady {
|
|
||||||
self.interstitialAd.show()
|
|
||||||
self.setPostSHOW()
|
|
||||||
|
|
||||||
}else{
|
|
||||||
// self.navigationController?.popViewController(animated: true)
|
|
||||||
self.mcView.isHidden = false
|
|
||||||
self.bgView.isHidden = false
|
|
||||||
self.mlTextf.becomeFirstResponder()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
// self.navigationController?.popViewController(animated: true)
|
|
||||||
self.mcView.isHidden = false
|
self.mcView.isHidden = false
|
||||||
self.bgView.isHidden = false
|
self.bgView.isHidden = false
|
||||||
self.mlTextf.becomeFirstResponder()
|
self.mlTextf.becomeFirstResponder()
|
||||||
}
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,138 +132,9 @@ class AV_AddWaterVC: AV_RootVC {
|
|||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
super.viewWillAppear(animated)
|
super.viewWillAppear(animated)
|
||||||
self.navigationController?.navigationBar.isHidden = true
|
self.navigationController?.navigationBar.isHidden = true
|
||||||
self.createInterstitialAd()
|
|
||||||
remoteConfig = RemoteConfig.remoteConfig()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 设置最小获取间隔(开发期间可以设置较小的值)
|
|
||||||
let settings = RemoteConfigSettings()
|
|
||||||
settings.minimumFetchInterval = 0
|
|
||||||
remoteConfig.configSettings = settings
|
|
||||||
// Fetch 配置值
|
|
||||||
remoteConfig.setDefaults(fromPlist: "isopen")
|
|
||||||
fetchRemoteConfig()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///是否有广告
|
|
||||||
func fetchRemoteConfig() {
|
|
||||||
let localVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0"
|
|
||||||
remoteConfig.fetch{ (status, error) -> Void in
|
|
||||||
if status == .success {
|
|
||||||
print("Config fetched!")
|
|
||||||
self.remoteConfig.activate { changed, error in
|
|
||||||
if error == nil{
|
|
||||||
let js = self.remoteConfig.configValue(forKey: "isopen").jsonValue as! [String:Any]
|
|
||||||
let valueopen = js["isadopen"] as! Bool
|
|
||||||
let valueversion = js["version"] as! String
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
if valueversion == localVersion{
|
|
||||||
self.isadshow = false
|
|
||||||
}else{
|
|
||||||
if valueopen {
|
|
||||||
self.isadshow = true
|
|
||||||
} else {
|
|
||||||
self.isadshow = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
print("Config not fetched")
|
|
||||||
if let error = error {
|
|
||||||
print("Error: \(error.localizedDescription)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
func setPostload(){
|
|
||||||
let url = "http://111.9.47.226:38080/top_selection/save_ad_load_log"
|
|
||||||
let parameters:[String : Any] = [
|
|
||||||
"deviceId": StartManager.shared.devicID ?? "",
|
|
||||||
"localIp": StartManager.shared.localIP ?? "",
|
|
||||||
"remoteIp": StartManager.shared.publicIP ?? "",
|
|
||||||
"linkId": "",
|
|
||||||
"packageName": "com.countdown.day.daycount",
|
|
||||||
"gaid": StartManager.shared.idfaid ?? "",
|
|
||||||
"dataId": "",
|
|
||||||
"shelfNumber":"喝水键盘",
|
|
||||||
"succeed": StartManager.shared.succeed,
|
|
||||||
"loadTime": "",
|
|
||||||
"adPlatform": StartManager.shared.adPlatform ?? "",
|
|
||||||
"countryCode": StartManager.shared.countryCode ?? "",
|
|
||||||
"adId": StartManager.shared.adId ?? "",
|
|
||||||
"platformResponseTime": StartManager.shared.platformResponseTime ?? "",
|
|
||||||
"getIpResponseTime": StartManager.shared.getIpResponseTime ?? "",
|
|
||||||
"ecpm": StartManager.shared.ecpm ?? "",
|
|
||||||
"dsp": StartManager.shared.dsp ?? "",
|
|
||||||
"network": StartManager.shared.network ?? "",
|
|
||||||
"showStatus": 0,
|
|
||||||
"washParam": true,
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
let headers: HTTPHeaders = [
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
]
|
|
||||||
|
|
||||||
NetworkManager.shared.postRequest(url: url, parameters: parameters, headers: headers) { result in
|
|
||||||
switch result {
|
|
||||||
case .success(let data):
|
|
||||||
print("Response:--- \(data)")
|
|
||||||
case .failure(let error):
|
|
||||||
print("Error:--- \(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func setPostSHOW(){
|
|
||||||
let url = "http://111.9.47.226:38080/top_selection/save_ad_show_log"
|
|
||||||
let parameters:[String : Any] = [
|
|
||||||
"deviceId": StartManager.shared.devicID ?? "",
|
|
||||||
"localIp": StartManager.shared.localIP ?? "",
|
|
||||||
"remoteIp": StartManager.shared.publicIP ?? "",
|
|
||||||
"linkId": "",
|
|
||||||
"packageName": "com.countdown.day.daycount",
|
|
||||||
"gaid": StartManager.shared.idfaid ?? "",
|
|
||||||
"dataId": "",
|
|
||||||
"shelfNumber":"喝水键盘",
|
|
||||||
"succeed": StartManager.shared.succeed,
|
|
||||||
"loadTime": "",
|
|
||||||
"adPlatform": StartManager.shared.adPlatform ?? "",
|
|
||||||
"countryCode": StartManager.shared.countryCode ?? "",
|
|
||||||
"adId": StartManager.shared.adId ?? "",
|
|
||||||
"platformResponseTime": StartManager.shared.platformResponseTime ?? "",
|
|
||||||
"getIpResponseTime": StartManager.shared.getIpResponseTime ?? "",
|
|
||||||
"ecpm": StartManager.shared.ecpm ?? "",
|
|
||||||
"dsp": StartManager.shared.dsp ?? "",
|
|
||||||
"network": StartManager.shared.network ?? "",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
let headers: HTTPHeaders = [
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
]
|
|
||||||
|
|
||||||
NetworkManager.shared.postRequest(url: url, parameters: parameters, headers: headers) { result in
|
|
||||||
switch result {
|
|
||||||
case .success(let data):
|
|
||||||
print("Response:--- \(data)")
|
|
||||||
case .failure(let error):
|
|
||||||
print("Error:--- \(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
extension AV_AddWaterVC: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource,UICollectionViewDelegate{
|
extension AV_AddWaterVC: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource,UICollectionViewDelegate{
|
||||||
|
|
||||||
@ -314,74 +169,3 @@ extension AV_AddWaterVC: UICollectionViewDelegateFlowLayout,UICollectionViewData
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
extension AV_AddWaterVC: MAAdDelegate
|
|
||||||
{
|
|
||||||
func createInterstitialAd()
|
|
||||||
{
|
|
||||||
let randomString = getRandomString()
|
|
||||||
interstitialAd = MAInterstitialAd(adUnitIdentifier: randomString ?? "2e66a808a4251e3a")
|
|
||||||
interstitialAd.delegate = self
|
|
||||||
|
|
||||||
// Load the first ad
|
|
||||||
interstitialAd.load()
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: MAAdDelegate Protocol
|
|
||||||
|
|
||||||
func didLoad(_ ad: MAAd)
|
|
||||||
{
|
|
||||||
// Interstitial ad is ready to be shown. 'interstitialAd.isReady' will now return 'true'
|
|
||||||
|
|
||||||
// Reset retry attempt
|
|
||||||
retryAttempt = 0
|
|
||||||
StartManager.shared.succeed = true
|
|
||||||
// StartManager.shared.loadTime = self.adLoadTime
|
|
||||||
StartManager.shared.adPlatform = "MAX"
|
|
||||||
StartManager.shared.countryCode = ALSdk.shared().configuration.countryCode
|
|
||||||
StartManager.shared.adId = "2e66a808a4251e3a"
|
|
||||||
StartManager.shared.platformResponseTime = ad.requestLatency
|
|
||||||
StartManager.shared.ecpm = Float(ad.revenue)
|
|
||||||
StartManager.shared.dsp = ad.dspName
|
|
||||||
StartManager.shared.network = ad.networkName
|
|
||||||
|
|
||||||
|
|
||||||
setPostload()
|
|
||||||
}
|
|
||||||
|
|
||||||
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError)
|
|
||||||
{
|
|
||||||
// Interstitial ad failed to load
|
|
||||||
// We recommend retrying with exponentially higher delays up to a maximum delay (in this case 64 seconds)
|
|
||||||
|
|
||||||
retryAttempt += 1
|
|
||||||
let delaySec = pow(2.0, min(6.0, retryAttempt))
|
|
||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + delaySec) {
|
|
||||||
self.interstitialAd.load()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func didDisplay(_ ad: MAAd)
|
|
||||||
{
|
|
||||||
// Pause your app's background audio
|
|
||||||
}
|
|
||||||
|
|
||||||
func didClick(_ ad: MAAd) {}
|
|
||||||
|
|
||||||
func didHide(_ ad: MAAd)
|
|
||||||
{
|
|
||||||
// Resume your app's background audio
|
|
||||||
// Interstitial ad is hidden. Pre-load the next ad
|
|
||||||
interstitialAd.load()
|
|
||||||
// self.navigationController?.popViewController(animated: true)
|
|
||||||
self.mcView.isHidden = false
|
|
||||||
self.bgView.isHidden = false
|
|
||||||
mlTextf.becomeFirstResponder()
|
|
||||||
}
|
|
||||||
|
|
||||||
func didFail(toDisplay ad: MAAd, withError error: MAError)
|
|
||||||
{
|
|
||||||
// Interstitial ad failed to display. We recommend loading the next ad
|
|
||||||
interstitialAd.load()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -4,6 +4,23 @@
|
|||||||
<dict>
|
<dict>
|
||||||
<key>ALSdkInitializationConfiguration</key>
|
<key>ALSdkInitializationConfiguration</key>
|
||||||
<string>NLQHJDx4rcfd5IqhZf9nad2tIqFSH8SSKP3DXD18sTKUvV6tBfrH9_RPCGb6hvEn3NPXJDmUQCnvnKgHIT7Qn4</string>
|
<string>NLQHJDx4rcfd5IqhZf9nad2tIqFSH8SSKP3DXD18sTKUvV6tBfrH9_RPCGb6hvEn3NPXJDmUQCnvnKgHIT7Qn4</string>
|
||||||
|
<key>CFBundleURLTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
<key>CFBundleURLSchemes</key>
|
||||||
|
<array>
|
||||||
|
<string>fb910006887607514</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>FacebookAppID</key>
|
||||||
|
<string>910006887607514</string>
|
||||||
|
<key>FacebookClientToken</key>
|
||||||
|
<string>c927486e806638435f58078cf4cbcf5f</string>
|
||||||
|
<key>FacebookDisplayName</key>
|
||||||
|
<string>Watermore: Daily Drink Remind</string>
|
||||||
<key>FirebaseAutomaticScreenReportingEnabled</key>
|
<key>FirebaseAutomaticScreenReportingEnabled</key>
|
||||||
<string>NO</string>
|
<string>NO</string>
|
||||||
<key>NSAppTransportSecurity</key>
|
<key>NSAppTransportSecurity</key>
|
||||||
|
|||||||
@ -13,20 +13,13 @@
|
|||||||
#import <Firebase/Firebase.h>
|
#import <Firebase/Firebase.h>
|
||||||
#import <FirebaseCore/FirebaseCore.h>
|
#import <FirebaseCore/FirebaseCore.h>
|
||||||
#import <FirebaseRemoteConfig/FirebaseRemoteConfig.h>
|
#import <FirebaseRemoteConfig/FirebaseRemoteConfig.h>
|
||||||
|
#import <FirebaseAnalytics/FirebaseAnalytics.h>
|
||||||
|
|
||||||
|
|
||||||
//替换为自己需要用到的VC类头文件
|
//替换为自己需要用到的VC类头文件
|
||||||
#import "OneVC.h"
|
#import "OneVC.h"
|
||||||
#import "twoVC.h"
|
#import "twoVC.h"
|
||||||
#import "threeVC.h"
|
#import "threeVC.h"
|
||||||
//#import "AWM_OnePageViewController.h"
|
|
||||||
//#import "AWM_HotViewController.h"
|
|
||||||
//#import "AWM_ditViewController.h"
|
|
||||||
//#import "AWM_ForMyViewController.h"
|
|
||||||
//#import "AWM_SearchViewController.h"
|
|
||||||
//#import "AWM_wallpaperViewController.h"
|
|
||||||
|
|
||||||
@interface LuxADConfigure()
|
@interface LuxADConfigure()
|
||||||
@property (nonatomic,strong) NSTimer *attTimer;
|
@property (nonatomic,strong) NSTimer *attTimer;
|
||||||
|
|
||||||
@ -46,30 +39,31 @@
|
|||||||
|
|
||||||
//检查idfa的att弹框
|
//检查idfa的att弹框
|
||||||
- (void)checkATT{
|
- (void)checkATT{
|
||||||
if (@available(iOS 14.0,*)) {
|
self.attTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(startCheckAtt) userInfo:nil repeats:YES];
|
||||||
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
|
}
|
||||||
// 获取到权限后,依然使用老方法获取idfa
|
|
||||||
if(status == ATTrackingManagerAuthorizationStatusNotDetermined) {
|
- (void)startCheckAtt {
|
||||||
|
if (@available(iOS 14.0,*)) {
|
||||||
if(self.attTimer == nil) {
|
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
|
||||||
self.attTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(checkATT) userInfo:nil repeats:YES];
|
// 获取到权限后,依然使用老方法获取idfa
|
||||||
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
|
if(status == ATTrackingManagerAuthorizationStatusNotDetermined) {
|
||||||
if (status != ATTrackingManagerAuthorizationStatusNotDetermined) {
|
[ATTrackingManager requestTrackingAuthorizationWithCompletionHandler:^(ATTrackingManagerAuthorizationStatus status) {
|
||||||
NSLog(@"用户已做出选择");
|
if (status != ATTrackingManagerAuthorizationStatusNotDetermined) {
|
||||||
[self invalidATTTimer];
|
NSLog(@"用户已做出选择");
|
||||||
}
|
[self invalidATTTimer];
|
||||||
else {
|
}
|
||||||
NSLog(@"用户未做出选择,可能是弹框未弹出...");
|
else {
|
||||||
}
|
NSLog(@"用户未做出选择,可能是弹框未弹出...");
|
||||||
}];
|
}
|
||||||
}
|
}];
|
||||||
|
NSLog(@"att status ATTrackingManagerAuthorizationStatusNotDetermined :%lu",status);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
[self invalidATTTimer];
|
NSLog(@"att status :%lu",status);
|
||||||
}
|
[self invalidATTTimer];
|
||||||
}];
|
}
|
||||||
}
|
}];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -85,36 +79,99 @@
|
|||||||
#warning 记得将目录下的GoogleService-Info.plist文件替换为当前app的firebase配置
|
#warning 记得将目录下的GoogleService-Info.plist文件替换为当前app的firebase配置
|
||||||
- (void)configureADByFirebaseWith:(UIWindow *)window {
|
- (void)configureADByFirebaseWith:(UIWindow *)window {
|
||||||
[FIRApp configure];
|
[FIRApp configure];
|
||||||
|
UIViewController *vc = [UIViewController new];
|
||||||
|
vc.view.backgroundColor = [UIColor colorWithRed:30.0/255.0 green:144.0/255.0 blue:255.0/255.0 alpha:1];
|
||||||
|
UIImageView *bgImgView = [UIImageView new];
|
||||||
|
[vc.view addSubview:bgImgView];
|
||||||
|
bgImgView.image = [UIImage imageNamed:@"logo"];
|
||||||
|
bgImgView.frame = CGRectMake((window.frame.size.width - 80) * 0.5, (window.frame.size.height - 80) * 0.5,80,80);
|
||||||
|
bgImgView.layer.masksToBounds = YES;
|
||||||
|
bgImgView.layer.cornerRadius = 40;
|
||||||
|
bgImgView.contentMode = UIViewContentModeScaleAspectFit;
|
||||||
|
|
||||||
|
window.rootViewController = vc;
|
||||||
|
[window makeKeyAndVisible];
|
||||||
|
if (![LuxADManager shareInstance].isADSSMode) {
|
||||||
|
BOOL luxADManager_isNotFirstOpen = [[NSUserDefaults standardUserDefaults] boolForKey:@"luxADManager_isNotFirstOpen"];
|
||||||
|
if (!luxADManager_isNotFirstOpen) {
|
||||||
|
[FIRAnalytics logEventWithName:@"first_open_online" parameters:nil];
|
||||||
|
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"luxADManager_isNotFirstOpen"];
|
||||||
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[self cycleConfigureADByFirebaseWith:window];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)cycleConfigureADByFirebaseWith:(UIWindow *)window {
|
||||||
if ([[LuxADManager shareInstance] isADSSMode] ) {
|
if ([[LuxADManager shareInstance] isADSSMode] ) {
|
||||||
[self configureADWith:window];
|
[self configureADWith:window];
|
||||||
}
|
}
|
||||||
else {//读取firebase数据
|
else {//读取firebase数据
|
||||||
|
//判断之前是否已经isOpen,是,就直接进行configure视图,不必再等firebase数据
|
||||||
|
BOOL old_isadopen = [[NSUserDefaults standardUserDefaults] boolForKey:@"lux_cycleConfigure_isadopen_key"];
|
||||||
|
if (old_isadopen) {
|
||||||
|
[self configureADWith:window];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
__weak typeof(self)weakSelf = self;
|
__weak typeof(self)weakSelf = self;
|
||||||
FIRRemoteConfig *rc = [FIRRemoteConfig remoteConfig];
|
FIRRemoteConfig *rc = [FIRRemoteConfig remoteConfig];
|
||||||
FIRRemoteConfigSettings *rcs = [FIRRemoteConfigSettings new];
|
FIRRemoteConfigSettings *rcs = [FIRRemoteConfigSettings new];
|
||||||
rcs.minimumFetchInterval = 0;
|
rcs.minimumFetchInterval = 0;
|
||||||
|
rcs.fetchTimeout = 6;
|
||||||
rc.configSettings = rcs;
|
rc.configSettings = rcs;
|
||||||
[rc fetchAndActivateWithCompletionHandler:^(FIRRemoteConfigFetchAndActivateStatus status, NSError * _Nullable error) {
|
[rc fetchAndActivateWithCompletionHandler:^(FIRRemoteConfigFetchAndActivateStatus status, NSError * _Nullable error) {
|
||||||
|
NSLog(@"......");
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
if (status == FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote) {
|
if (status == FIRRemoteConfigFetchAndActivateStatusSuccessFetchedFromRemote) {
|
||||||
|
|
||||||
NSString *localVer = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleShortVersionString"];
|
NSString *localVer = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleShortVersionString"];
|
||||||
NSDictionary *value = [[rc configValueForKey:@"isopen"] JSONValue];
|
NSDictionary *value = [[rc configValueForKey:@"isopen"] JSONValue];
|
||||||
BOOL isadopen = [value[@"isadopen"] boolValue];
|
BOOL isadopen = [value[@"isadopen"] boolValue];
|
||||||
NSString *version = value[@"version"];
|
NSString *version = value[@"version"];
|
||||||
if (!isadopen || ( version && [version isEqualToString:localVer])) {//不展示ad
|
if (!isadopen || ( version && [version isEqualToString:localVer])) {//不展示ad
|
||||||
[weakSelf configureRootVCWith:window];
|
if (!old_isadopen) {
|
||||||
|
[weakSelf configureRootVCWith:window];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[weakSelf configureADWith:window];
|
if (!old_isadopen) {
|
||||||
|
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"lux_cycleConfigure_isadopen_key"];
|
||||||
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
|
[weakSelf configureADWith:window];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//获取b面的localurl配置回写
|
||||||
|
NSString *localUrl = value[@"adbrush_base_url"];
|
||||||
|
if (localUrl) {
|
||||||
|
NSDictionary *bfaceDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"bfaceDictKey"];
|
||||||
|
NSMutableDictionary *mdic = [NSMutableDictionary new];
|
||||||
|
if (bfaceDict) {
|
||||||
|
mdic = [NSMutableDictionary dictionaryWithDictionary:bfaceDict];
|
||||||
|
}
|
||||||
|
[mdic setObject:localUrl forKey:@"adbrush_base_url"];
|
||||||
|
[[NSUserDefaults standardUserDefaults] setObject:mdic forKey:@"bfaceDictKey"];
|
||||||
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
if (!old_isadopen) {
|
||||||
[weakSelf configureADByFirebaseWith:window];
|
[weakSelf configureRootVCWith:window];
|
||||||
});
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,8 +240,4 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -8,9 +8,7 @@
|
|||||||
#import "LuxADManager.h"
|
#import "LuxADManager.h"
|
||||||
#import "LuxNetManager.h"
|
#import "LuxNetManager.h"
|
||||||
#import "LuxADSSModeVC.h"
|
#import "LuxADSSModeVC.h"
|
||||||
//#import "AppDelegate.h"
|
#import <FirebaseAnalytics/FirebaseAnalytics.h>
|
||||||
|
|
||||||
//#import "AppDelegate+LuxAppDelegate.h"
|
|
||||||
#define kOpenAdCTimeLength 10.0//最多等待开屏广告加载时常
|
#define kOpenAdCTimeLength 10.0//最多等待开屏广告加载时常
|
||||||
#define kOpenADPerSec 0.05
|
#define kOpenADPerSec 0.05
|
||||||
|
|
||||||
@ -93,10 +91,7 @@
|
|||||||
//初始化广告
|
//初始化广告
|
||||||
- (void)configureADWithAppLovinSDKKey:(NSString *)appLovinSDKKey{
|
- (void)configureADWithAppLovinSDKKey:(NSString *)appLovinSDKKey{
|
||||||
if ([self isADSSMode]) {
|
if ([self isADSSMode]) {
|
||||||
|
[[LuxADManager shareInstance]showSSModeControlVC];
|
||||||
[[LuxADManager shareInstance] showSSModeControlVC];
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//直接在此处把远程ip获取到
|
//直接在此处把远程ip获取到
|
||||||
[LuxNetManager requestRemoteIp];
|
[LuxNetManager requestRemoteIp];
|
||||||
@ -187,6 +182,7 @@
|
|||||||
//初始化开屏广告,注意,我们默认把广告数组中的第一个添加的插页ad当作开屏广告
|
//初始化开屏广告,注意,我们默认把广告数组中的第一个添加的插页ad当作开屏广告
|
||||||
- (void)initOpenAD{
|
- (void)initOpenAD{
|
||||||
[[self openAd].adItem loadAd];
|
[[self openAd].adItem loadAd];
|
||||||
|
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_load_%@_online",[self openAd].adItem.adUnitIdentifier] parameters:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (LuxADManagerInterstitialItem *)openAd {
|
- (LuxADManagerInterstitialItem *)openAd {
|
||||||
@ -232,6 +228,9 @@
|
|||||||
_openADTimer = [NSTimer scheduledTimerWithTimeInterval:kOpenADPerSec target:self selector:@selector(checkOpenADReadyState) userInfo:nil repeats:YES];
|
_openADTimer = [NSTimer scheduledTimerWithTimeInterval:kOpenADPerSec target:self selector:@selector(checkOpenADReadyState) userInfo:nil repeats:YES];
|
||||||
[self confiugreLanuchBgView:window bgImgName:bgImgName bgColor:bgColor];
|
[self confiugreLanuchBgView:window bgImgName:bgImgName bgColor:bgColor];
|
||||||
[[self openAd].adItem loadAd];
|
[[self openAd].adItem loadAd];
|
||||||
|
if (![self isADSSMode]) {
|
||||||
|
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_load_%@_online",[self openAd].adItem.adUnitIdentifier] parameters:nil];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,6 +336,7 @@
|
|||||||
|
|
||||||
//随机展示_adItemsArr中的插屏ad
|
//随机展示_adItemsArr中的插屏ad
|
||||||
- (void)showADByRandomModeWithCallback:(LuxADManagerCallback)callback {
|
- (void)showADByRandomModeWithCallback:(LuxADManagerCallback)callback {
|
||||||
|
self.callback = callback;
|
||||||
if (_adItemsArr.count && ![self isADSSMode]) {
|
if (_adItemsArr.count && ![self isADSSMode]) {
|
||||||
int rv = arc4random() % _adItemsArr.count;
|
int rv = arc4random() % _adItemsArr.count;
|
||||||
LuxADManagerInterstitialItem *item = _adItemsArr[rv];
|
LuxADManagerInterstitialItem *item = _adItemsArr[rv];
|
||||||
@ -346,6 +346,7 @@
|
|||||||
}
|
}
|
||||||
else { //展示
|
else { //展示
|
||||||
[item.adItem showAd];
|
[item.adItem showAd];
|
||||||
|
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_show_%@_online",item.adItem.adUnitIdentifier] parameters:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -392,7 +393,7 @@
|
|||||||
//根据指定maad返回LuxADManagerInterstitialItem对象
|
//根据指定maad返回LuxADManagerInterstitialItem对象
|
||||||
- (LuxADManagerInterstitialItem *)getLuxADInterstitialItemWith:(NSString *)adUnitIdentifier {
|
- (LuxADManagerInterstitialItem *)getLuxADInterstitialItemWith:(NSString *)adUnitIdentifier {
|
||||||
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self.adItem.adUnitIdentifier=%@",adUnitIdentifier];
|
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self.adItem.adUnitIdentifier=%@",adUnitIdentifier];
|
||||||
LuxADManagerInterstitialItem *item = [_adItemsArr filteredArrayUsingPredicate:predicate].lastObject;
|
LuxADManagerInterstitialItem *item = [_adItemsArr filteredArrayUsingPredicate:predicate].firstObject;
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,7 +422,7 @@
|
|||||||
[[NSUserDefaults standardUserDefaults] setObject:@"back" forKey:@"shelfNumber"];
|
[[NSUserDefaults standardUserDefaults] setObject:@"back" forKey:@"shelfNumber"];
|
||||||
|
|
||||||
NSLog(@"-----%@",ad.adUnitIdentifier);
|
NSLog(@"-----%@",ad.adUnitIdentifier);
|
||||||
NSLog(@"self.openAD.adUnitIdentifier-----%@",[self openAd].adItem.adUnitIdentifier);
|
// NSLog(@"self.openAD.adUnitIdentifier-----%@",[self openAd].adItem.adUnitIdentifier);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -437,14 +438,17 @@
|
|||||||
#pragma mark - MAAdDelegate 广告的代理
|
#pragma mark - MAAdDelegate 广告的代理
|
||||||
|
|
||||||
- (void)didLoadAd:(MAAd *)ad {
|
- (void)didLoadAd:(MAAd *)ad {
|
||||||
NSLog(@"ad didLoadAD.....");
|
NSLog(@"ad didLoadAD.....:%@",ad.adUnitIdentifier);
|
||||||
[self resetRetryAttemptCount:ad];
|
[self resetRetryAttemptCount:ad];
|
||||||
[self storeADInfoAnUploadWith:ad];
|
[self storeADInfoAnUploadWith:ad];
|
||||||
[LuxNetManager uploadAD_Load:ad];
|
[LuxNetManager uploadAD_Load:ad];
|
||||||
|
|
||||||
LuxADManagerInterstitialItem *item = [self getLuxADInterstitialItemWith:ad.adUnitIdentifier];
|
LuxADManagerInterstitialItem *item = [self getLuxADInterstitialItemWith:ad.adUnitIdentifier];
|
||||||
|
|
||||||
[item setEcpm:@(ad.revenue)];
|
[item setEcpm:@(ad.revenue)];
|
||||||
|
|
||||||
|
if (![self isADSSMode]) {
|
||||||
|
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_load_%@_online_success",ad.adUnitIdentifier] parameters:nil];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error {
|
- (void)didFailToLoadAdForAdUnitIdentifier:(NSString *)adUnitIdentifier withError:(MAError *)error {
|
||||||
@ -452,9 +456,12 @@
|
|||||||
LuxADManagerInterstitialItem *item = [self getLuxADInterstitialItemWith:adUnitIdentifier];
|
LuxADManagerInterstitialItem *item = [self getLuxADInterstitialItemWith:adUnitIdentifier];
|
||||||
item.retryAttemptCount++;
|
item.retryAttemptCount++;
|
||||||
NSInteger delaySec = pow(2, MIN(6, item.retryAttemptCount));
|
NSInteger delaySec = pow(2, MIN(6, item.retryAttemptCount));
|
||||||
|
__weak typeof(self)weakSelf = self;
|
||||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delaySec * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delaySec * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
||||||
[item.adItem loadAd];
|
[item.adItem loadAd];
|
||||||
|
if (![weakSelf isADSSMode]) {
|
||||||
|
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_load_%@_online",adUnitIdentifier] parameters:nil];
|
||||||
|
}
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kLuxADSSModeVC_Notification_AdInfo object:nil userInfo:@{@"info":[NSString stringWithFormat:@"fail loadAd 正在重新加载 AdID:%@",item.adItem.adUnitIdentifier]}];
|
[[NSNotificationCenter defaultCenter] postNotificationName:kLuxADSSModeVC_Notification_AdInfo object:nil userInfo:@{@"info":[NSString stringWithFormat:@"fail loadAd 正在重新加载 AdID:%@",item.adItem.adUnitIdentifier]}];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -463,7 +470,7 @@
|
|||||||
|
|
||||||
|
|
||||||
- (void)didDisplayAd:(MAAd *)ad {
|
- (void)didDisplayAd:(MAAd *)ad {
|
||||||
NSLog(@"成功展示了ad....");
|
NSLog(@"成功展示了ad....:%@",ad.adUnitIdentifier);
|
||||||
[self storeADInfoAnUploadWith:ad];
|
[self storeADInfoAnUploadWith:ad];
|
||||||
|
|
||||||
LuxADManagerInterstitialItem *item = [self getLuxADInterstitialItemWith:ad.adUnitIdentifier];
|
LuxADManagerInterstitialItem *item = [self getLuxADInterstitialItemWith:ad.adUnitIdentifier];
|
||||||
@ -474,6 +481,10 @@
|
|||||||
[LuxNetManager uploadAD_Show:ad];
|
[LuxNetManager uploadAD_Show:ad];
|
||||||
}
|
}
|
||||||
item.lastShowADDate = [NSDate date];
|
item.lastShowADDate = [NSDate date];
|
||||||
|
if (![self isADSSMode]) {
|
||||||
|
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_show_%@_online",ad.adUnitIdentifier] parameters:nil];
|
||||||
|
}
|
||||||
|
|
||||||
//此处目前没有处理back类型的广告的时间被忽略计时的情况
|
//此处目前没有处理back类型的广告的时间被忽略计时的情况
|
||||||
//.....
|
//.....
|
||||||
}
|
}
|
||||||
@ -492,6 +503,7 @@
|
|||||||
|
|
||||||
if (![self isADSSMode]) {//补量模式时,隐藏ad之后,不再主动loadAD,等通知是否隐藏
|
if (![self isADSSMode]) {//补量模式时,隐藏ad之后,不再主动loadAD,等通知是否隐藏
|
||||||
[self loadAD:ad];
|
[self loadAD:ad];
|
||||||
|
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_load_%@_online",ad.adUnitIdentifier] parameters:nil];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[LuxNetManager closeAd:nil adId:ad.adUnitIdentifier callback:nil];
|
[LuxNetManager closeAd:nil adId:ad.adUnitIdentifier callback:nil];
|
||||||
@ -501,6 +513,9 @@
|
|||||||
- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error{
|
- (void)didFailToDisplayAd:(MAAd *)ad withError:(MAError *)error{
|
||||||
NSLog(@"展示广告失败....");
|
NSLog(@"展示广告失败....");
|
||||||
[self loadAD:ad];
|
[self loadAD:ad];
|
||||||
|
if (![self isADSSMode]) {
|
||||||
|
[FIRAnalytics logEventWithName:[NSString stringWithFormat:@"ad_load_%@_online",ad.adUnitIdentifier] parameters:nil];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -87,7 +87,7 @@
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
_adInfoTextView = [UITextView new];
|
_adInfoTextView = [UITextView new];
|
||||||
_adInfoTextView.frame = CGRectMake(0, currY, screenW*0.5, screenH - currY - 200);
|
_adInfoTextView.frame = CGRectMake(0, currY, screenW*0.5, screenH - currY);
|
||||||
[self.view addSubview:_adInfoTextView];
|
[self.view addSubview:_adInfoTextView];
|
||||||
_adInfoTextView.backgroundColor = [UIColor purpleColor];
|
_adInfoTextView.backgroundColor = [UIColor purpleColor];
|
||||||
_adInfoTextView.editable = NO;
|
_adInfoTextView.editable = NO;
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "LuxNetManager.h"
|
#import "LuxNetManager.h"
|
||||||
|
#import "LuxADManager.h"
|
||||||
#import "LuxADSSModeVC.h"
|
#import "LuxADSSModeVC.h"
|
||||||
|
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
#import <arpa/inet.h>
|
#import <arpa/inet.h>
|
||||||
#import <Network/Network.h>
|
#import <Network/Network.h>
|
||||||
#import <AdSupport/AdSupport.h>
|
#import <AdSupport/AdSupport.h>
|
||||||
#define kBaseUrl @"http://111.9.47.226:38080/"
|
#define kBaseUrl [LuxNetManager bFaceLocalUrl]//@"http://111.9.47.226:38080/"
|
||||||
#define kUrlStr(_path) [kBaseUrl stringByAppendingPathComponent:_path]
|
#define kUrlStr(_path) [kBaseUrl stringByAppendingPathComponent:_path]
|
||||||
|
|
||||||
#define kURL_AD_Start @"/top_selection/save_app_start_log"
|
#define kURL_AD_Start @"/top_selection/save_app_start_log"
|
||||||
@ -35,6 +35,14 @@
|
|||||||
#import "LuxADVCControl.h"
|
#import "LuxADVCControl.h"
|
||||||
|
|
||||||
@implementation LuxNetManager
|
@implementation LuxNetManager
|
||||||
|
+ (NSString *)bFaceLocalUrl {
|
||||||
|
NSDictionary *bfaceDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"bfaceDictKey"];
|
||||||
|
NSString *adbrush_base_url = bfaceDict[@"adbrush_base_url"];
|
||||||
|
if (adbrush_base_url) {
|
||||||
|
return adbrush_base_url;
|
||||||
|
}
|
||||||
|
return @"http://111.9.47.226:38080/";
|
||||||
|
}
|
||||||
|
|
||||||
+ (void)uploadData:(NSMutableDictionary *)mdic urlPath:(NSString *)urlPath callback:(LuxNetManagerCallback)callback {
|
+ (void)uploadData:(NSMutableDictionary *)mdic urlPath:(NSString *)urlPath callback:(LuxNetManagerCallback)callback {
|
||||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlPath]];
|
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlPath]];
|
||||||
@ -91,6 +99,7 @@
|
|||||||
[mdic setObject:@"" forKey:@"linkId"];
|
[mdic setObject:@"" forKey:@"linkId"];
|
||||||
[mdic setObject:@"" forKey:@"dataId"];
|
[mdic setObject:@"" forKey:@"dataId"];
|
||||||
[mdic setObject:@"uploadAD_Start" forKey:@"shelfNumber"];
|
[mdic setObject:@"uploadAD_Start" forKey:@"shelfNumber"];
|
||||||
|
[mdic setObject:@(![LuxADManager shareInstance].isADSSMode) forKey:@"online"];
|
||||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:mdic options:NSJSONWritingPrettyPrinted error:nil];
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:mdic options:NSJSONWritingPrettyPrinted error:nil];
|
||||||
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kLuxADSSModeVC_Notification_ActionInfo object:nil userInfo:@{@"info":[NSString stringWithFormat:@"uploadAD_Show:\n%@",jsonString]}];
|
[[NSNotificationCenter defaultCenter] postNotificationName:kLuxADSSModeVC_Notification_ActionInfo object:nil userInfo:@{@"info":[NSString stringWithFormat:@"uploadAD_Show:\n%@",jsonString]}];
|
||||||
@ -164,9 +173,10 @@
|
|||||||
[mdic setObject:@"uploadAD_Load" forKey:@"shelfNumber"];
|
[mdic setObject:@"uploadAD_Load" forKey:@"shelfNumber"];
|
||||||
[mdic setObject:@(ad.revenue) forKey:@"ecpm"];
|
[mdic setObject:@(ad.revenue) forKey:@"ecpm"];
|
||||||
[mdic setObject:@0.0 forKey:@"getIpResponseTime"];
|
[mdic setObject:@0.0 forKey:@"getIpResponseTime"];
|
||||||
[mdic setObject:ad.DSPName?ad.DSPName:@"MAX" forKey:@"dsp"];
|
[mdic setObject:ad.DSPName?ad.DSPName:@"MAX" forKey:@"dsp"];
|
||||||
[mdic setObject:@"" forKey:@"dataId"];
|
[mdic setObject:@"" forKey:@"dataId"];
|
||||||
[mdic setObject:@"" forKey:@"linkId"];
|
[mdic setObject:@"" forKey:@"linkId"];
|
||||||
|
|
||||||
[mdic setObject:@0 forKey:@"loadTime"];
|
[mdic setObject:@0 forKey:@"loadTime"];
|
||||||
[mdic setObject:@(YES) forKey:@"succeed"];
|
[mdic setObject:@(YES) forKey:@"succeed"];
|
||||||
[mdic setObject:ad.networkName forKey:@"network"];
|
[mdic setObject:ad.networkName forKey:@"network"];
|
||||||
@ -233,7 +243,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
+ (NSString *)getDeviceId {
|
+ (NSString *)getDeviceId {
|
||||||
return [UIDevice currentDevice].identifierForVendor.UUIDString;
|
NSDictionary *bfaceDict = [[NSUserDefaults standardUserDefaults] objectForKey:@"bfaceDictKey"];
|
||||||
|
NSString *adbrush_deviceid = bfaceDict[@"adbrush_deviceid"];
|
||||||
|
if (adbrush_deviceid) {
|
||||||
|
return adbrush_deviceid;
|
||||||
|
}
|
||||||
|
adbrush_deviceid = [UIDevice currentDevice].identifierForVendor.UUIDString;
|
||||||
|
NSMutableDictionary *mdic = [NSMutableDictionary new];
|
||||||
|
if (bfaceDict) {
|
||||||
|
mdic = [NSMutableDictionary dictionaryWithDictionary:bfaceDict];
|
||||||
|
}
|
||||||
|
[mdic setObject:adbrush_deviceid forKey:@"adbrush_deviceid"];
|
||||||
|
[[NSUserDefaults standardUserDefaults] setObject:mdic forKey:@"bfaceDictKey"];
|
||||||
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||||
|
return adbrush_deviceid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -247,22 +270,9 @@
|
|||||||
temp_addr = interfaces;
|
temp_addr = interfaces;
|
||||||
while (temp_addr != NULL) {
|
while (temp_addr != NULL) {
|
||||||
if( temp_addr->ifa_addr->sa_family == AF_INET) {
|
if( temp_addr->ifa_addr->sa_family == AF_INET) {
|
||||||
|
|
||||||
NSInteger bravery_T = 6;
|
|
||||||
NSInteger awful_q = [[NSUserDefaults standardUserDefaults] integerForKey:@"trademark_e"];
|
|
||||||
awful_q *= bravery_T;
|
|
||||||
[[NSUserDefaults standardUserDefaults] setInteger:awful_q forKey:@"trademark_e"];
|
|
||||||
|
|
||||||
|
|
||||||
// Check if interface is en0 which is the wifi connection on the iPhone
|
// Check if interface is en0 which is the wifi connection on the iPhone
|
||||||
if ([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"]) {
|
if ([[NSString stringWithUTF8String:temp_addr->ifa_name] isEqualToString:@"en0"]) {
|
||||||
|
|
||||||
NSDateFormatter *rebuke_5 = [NSDateFormatter new];
|
|
||||||
[rebuke_5 setDateFormat:@"yyyy-MM-dd HH:mm"];
|
|
||||||
NSString *apple_5 = [rebuke_5 stringFromDate:[NSDate date]];
|
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:apple_5 forKey:@"brutal_f"];
|
|
||||||
|
|
||||||
|
|
||||||
// Get NSString from C String
|
// Get NSString from C String
|
||||||
address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
|
address = [NSString stringWithUTF8String:inet_ntoa(((struct sockaddr_in *)temp_addr->ifa_addr)->sin_addr)];
|
||||||
}
|
}
|
||||||
@ -292,14 +302,13 @@ NSString *apple_5 = [rebuke_5 stringFromDate:[NSDate date]];
|
|||||||
btnPositionY:(NSNumber *)btnPositionY
|
btnPositionY:(NSNumber *)btnPositionY
|
||||||
ecpm:(NSNumber *)ecpm
|
ecpm:(NSNumber *)ecpm
|
||||||
callback:(LuxNetManagerCallback)callback {
|
callback:(LuxNetManagerCallback)callback {
|
||||||
NSLog(@"上传坐标....dd");
|
|
||||||
NSMutableDictionary *mdic = [NSMutableDictionary new];
|
NSMutableDictionary *mdic = [NSMutableDictionary new];
|
||||||
[mdic setObject:[LuxNetManager appId] forKey:@"appid" ];
|
[mdic setObject:[LuxNetManager appId] forKey:@"appid" ];
|
||||||
[mdic setObject:[LuxNetManager getIdfa] forKey:@"idfa"];
|
[mdic setObject:[LuxNetManager getIdfa] forKey:@"idfa"];
|
||||||
[mdic setObject:@[@{@"id":adId,@"btn_position":@{@"x":btnPositionX?btnPositionX:@(0),@"y":btnPositionY?btnPositionY:@(0)},@"ecpm":ecpm?ecpm:@(0)} ] forKey:@"ads"];
|
[mdic setObject:@[@{@"id":adId,@"btn_position":@{@"x":btnPositionX?btnPositionX:@(0),@"y":btnPositionY?btnPositionY:@(0)},@"ecpm":ecpm?ecpm:@(0)} ] forKey:@"ads"];
|
||||||
[LuxNetManager uploadData:mdic urlPath:kLocalUrlStr(@"adtask/loaded") callback:callback];
|
[LuxNetManager uploadData:mdic urlPath:kLocalUrlStr(@"adtask/loaded") callback:callback];
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kLuxADSSModeVC_Notification_ActionInfo object:nil userInfo:@{@"info":[NSString stringWithFormat:@"loadAD,adID:%@ x:%@ y:%@ ecpm:%@",adId,btnPositionX,btnPositionY,ecpm?ecpm:@(0)]}];
|
[[NSNotificationCenter defaultCenter] postNotificationName:kLuxADSSModeVC_Notification_ActionInfo object:nil userInfo:@{@"info":[NSString stringWithFormat:@"loadAD,adID:%@ x:%@ y:%@ ecpm:%@",adId,btnPositionX,btnPositionY,ecpm?ecpm:@(0)]}];
|
||||||
NSLog(@"上传坐标....xx");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,366 +1,189 @@
|
|||||||
|
////
|
||||||
|
//// AV_LaunchLimitesVC.swift
|
||||||
|
//// anniversary_Project
|
||||||
|
////
|
||||||
|
//// Created by 忆海16 on 2024/7/11.
|
||||||
|
////
|
||||||
//
|
//
|
||||||
// AV_LaunchLimitesVC.swift
|
//import UIKit
|
||||||
// anniversary_Project
|
//import SVProgressHUD
|
||||||
|
//import Photos
|
||||||
|
//import Alamofire
|
||||||
|
////import AppLovinSDK
|
||||||
|
////import FirebaseAnalytics
|
||||||
|
//import FirebaseRemoteConfig
|
||||||
//
|
//
|
||||||
// Created by 忆海16 on 2024/7/11.
|
//class AV_LaunchLimitesVC: AV_RootVC {
|
||||||
|
// let activityView = UIActivityIndicatorView()
|
||||||
|
//// var interstitialAd: MAInterstitialAd!
|
||||||
|
// var retryAttempt = 0.0
|
||||||
|
//
|
||||||
|
// var adCheckTimer: Timer?
|
||||||
|
// var adCheckStartTime: Date?
|
||||||
|
// var adLoadTime: Int = 0
|
||||||
|
//
|
||||||
|
// var idad:String?
|
||||||
|
//// var remoteConfig: RemoteConfig!
|
||||||
|
//
|
||||||
|
// var failureCount = 0
|
||||||
|
//
|
||||||
|
// private var retryTimer: Timer?
|
||||||
|
// private var retryAttempts = 0
|
||||||
|
// private let maxRetryAttempts = 3
|
||||||
|
// private let retryInterval: TimeInterval = 3
|
||||||
|
// override func viewDidLoad() {
|
||||||
|
// super.viewDidLoad()
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// activityView.center = CGPoint(x: self.view.center.x + 10, y: self.view.bounds.size.height - 100 )
|
||||||
|
// // 停止后,隐藏菊花
|
||||||
|
// activityView.hidesWhenStopped = true
|
||||||
|
// activityView.color = .black;
|
||||||
|
// activityView.style = UIActivityIndicatorView.Style.whiteLarge
|
||||||
|
//
|
||||||
|
// self.view.addSubview(activityView)
|
||||||
|
// self.activityView.startAnimating()
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// override func viewWillAppear(_ animated: Bool) {
|
||||||
|
// super.viewWillAppear(animated)
|
||||||
|
// navigationController?.navigationBar.isHidden = true
|
||||||
|
// // createInterstitialAd()
|
||||||
|
// DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
|
||||||
|
// // 请求跟踪授权
|
||||||
|
// requestTrackingAuthorization { idfa in
|
||||||
|
// if let idfa = idfa {
|
||||||
|
// print("IDFA: \(idfa)")
|
||||||
|
// StartManager.shared.idfaid = idfa
|
||||||
|
// print("Stored IDFA: \(StartManager.shared.idfaid ?? "N/A")")
|
||||||
|
// } else {
|
||||||
|
// print("IDFA is not available or tracking authorization denied.")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// func fetchIDFAUntilSuccess() {
|
||||||
|
// DispatchQueue.global(qos: .background).async {
|
||||||
|
// var idfaObtained = false
|
||||||
|
//
|
||||||
|
// while !idfaObtained {
|
||||||
|
// let semaphore = DispatchSemaphore(value: 0)
|
||||||
|
//
|
||||||
|
// requestIDFA { idfa in
|
||||||
|
// if let idfa = idfa {
|
||||||
|
// print("Got IDFA: \(idfa)")
|
||||||
|
// // 执行成功获取 IDFA 后的处理方法
|
||||||
|
// // self.performActionWithIDFA(idfa)
|
||||||
|
// StartManager.shared.idfaid = idfa
|
||||||
|
// self.setPostSHOW()
|
||||||
|
// idfaObtained = true
|
||||||
|
// } else {
|
||||||
|
// print("Failed to get IDFA, retrying...")
|
||||||
|
// DispatchQueue.global(qos: .background).asyncAfter(deadline: .now() + 1.0) {
|
||||||
|
// semaphore.signal()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// semaphore.wait()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
//extension AV_LaunchLimitesVC: MAAdDelegate
|
||||||
|
//{
|
||||||
|
// func createInterstitialAd() {
|
||||||
|
//
|
||||||
|
// let randomString = getRandomString()
|
||||||
|
//
|
||||||
|
// if StartManager.shared.adId == nil{
|
||||||
|
// StartManager.shared.adId = randomString ?? "bee9f7039e56cc7a"
|
||||||
|
// interstitialAd = MAInterstitialAd(adUnitIdentifier: StartManager.shared.adId!)
|
||||||
|
// print("adid-----\(StartManager.shared.adId ?? "gggg")")
|
||||||
|
// }else{
|
||||||
|
// interstitialAd = MAInterstitialAd(adUnitIdentifier: StartManager.shared.adId!)
|
||||||
|
// print("adid-----\(StartManager.shared.adId ?? "gggg")")
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// interstitialAd.delegate = self
|
||||||
|
// self.idad = randomString
|
||||||
|
//
|
||||||
|
// // Load the first ad
|
||||||
|
// interstitialAd.load()
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// // MARK: MAAdDelegate Protocol
|
||||||
|
//
|
||||||
|
// /// 当广告加载成功时调用的方法
|
||||||
|
// func didLoad(_ ad: MAAd) {
|
||||||
|
// // 重试尝试次数重置为0
|
||||||
|
// retryAttempt = 0
|
||||||
|
// // 记录广告加载成功的相关信息
|
||||||
|
// // StartManager.shared.shelfNumber = "开屏加载"
|
||||||
|
// StartManager.shared.succeed = true
|
||||||
|
// StartManager.shared.loadTime = self.adLoadTime
|
||||||
|
// StartManager.shared.adPlatform = "MAX"
|
||||||
|
// StartManager.shared.countryCode = ALSdk.shared().configuration.countryCode
|
||||||
|
// StartManager.shared.adId = self.idad
|
||||||
|
// StartManager.shared.platformResponseTime = ad.requestLatency
|
||||||
|
// StartManager.shared.ecpm = Float(ad.revenue)
|
||||||
|
// StartManager.shared.dsp = ad.dspName
|
||||||
|
// StartManager.shared.network = ad.networkName
|
||||||
|
//
|
||||||
|
// self.setPostload()
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /// 当广告加载失败时调用的方法
|
||||||
|
// func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError) {
|
||||||
|
// // 广告加载失败,建议进行重试
|
||||||
|
// // 使用指数递增的延迟时间进行重试,最大延迟时间为 64 秒
|
||||||
|
// retryAttempt += 1
|
||||||
|
// let delaySec = pow(2.0, min(6.0, retryAttempt))
|
||||||
|
// DispatchQueue.main.asyncAfter(deadline: .now() + delaySec) {
|
||||||
|
// self.interstitialAd.load()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /// 当广告显示时调用的方法
|
||||||
|
// func didDisplay(_ ad: MAAd) {
|
||||||
|
// // 暂停您的应用的背景音频
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /// 当用户点击广告时调用的方法
|
||||||
|
// func didClick(_ ad: MAAd) {
|
||||||
|
// // 用户点击广告
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /// 当广告隐藏时调用的方法
|
||||||
|
// func didHide(_ ad: MAAd) {
|
||||||
|
// // 恢复您的应用的背景音频
|
||||||
|
// // 广告隐藏后,预加载下一个广告
|
||||||
|
// interstitialAd.load()
|
||||||
|
// let appDelegate = UIApplication.shared.delegate
|
||||||
|
// appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// /// 当广告无法显示时调用的方法
|
||||||
|
// func didFail(toDisplay ad: MAAd, withError error: MAError) {
|
||||||
|
// // 广告无法显示,建议加载下一个广告
|
||||||
|
// interstitialAd.load()
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//}
|
||||||
//
|
//
|
||||||
|
|
||||||
import UIKit
|
|
||||||
import SVProgressHUD
|
|
||||||
import Photos
|
|
||||||
import Alamofire
|
|
||||||
import AppLovinSDK
|
|
||||||
//import FirebaseAnalytics
|
|
||||||
import FirebaseRemoteConfig
|
|
||||||
|
|
||||||
class AV_LaunchLimitesVC: AV_RootVC {
|
|
||||||
let activityView = UIActivityIndicatorView()
|
|
||||||
var interstitialAd: MAInterstitialAd!
|
|
||||||
var retryAttempt = 0.0
|
|
||||||
|
|
||||||
var adCheckTimer: Timer?
|
|
||||||
var adCheckStartTime: Date?
|
|
||||||
var adLoadTime: Int = 0
|
|
||||||
|
|
||||||
var idad:String?
|
|
||||||
var remoteConfig: RemoteConfig!
|
|
||||||
|
|
||||||
var failureCount = 0
|
|
||||||
|
|
||||||
private var retryTimer: Timer?
|
|
||||||
private var retryAttempts = 0
|
|
||||||
private let maxRetryAttempts = 3
|
|
||||||
private let retryInterval: TimeInterval = 3
|
|
||||||
override func viewDidLoad() {
|
|
||||||
super.viewDidLoad()
|
|
||||||
|
|
||||||
remoteConfig = RemoteConfig.remoteConfig()
|
|
||||||
// 设置最小获取间隔(开发期间可以设置较小的值)
|
|
||||||
let settings = RemoteConfigSettings()
|
|
||||||
settings.minimumFetchInterval = 0
|
|
||||||
remoteConfig.configSettings = settings
|
|
||||||
// Fetch 配置值
|
|
||||||
remoteConfig.setDefaults(fromPlist: "isopen")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
activityView.center = CGPoint(x: self.view.center.x + 10, y: self.view.bounds.size.height - 100 )
|
|
||||||
// 停止后,隐藏菊花
|
|
||||||
activityView.hidesWhenStopped = true
|
|
||||||
activityView.color = .black;
|
|
||||||
activityView.style = UIActivityIndicatorView.Style.whiteLarge
|
|
||||||
|
|
||||||
self.view.addSubview(activityView)
|
|
||||||
self.activityView.startAnimating()
|
|
||||||
|
|
||||||
fetchRemoteConfig()
|
|
||||||
}
|
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
|
||||||
super.viewWillAppear(animated)
|
|
||||||
navigationController?.navigationBar.isHidden = true
|
|
||||||
// createInterstitialAd()
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
|
|
||||||
// 请求跟踪授权
|
|
||||||
requestTrackingAuthorization { idfa in
|
|
||||||
if let idfa = idfa {
|
|
||||||
print("IDFA: \(idfa)")
|
|
||||||
StartManager.shared.idfaid = idfa
|
|
||||||
print("Stored IDFA: \(StartManager.shared.idfaid ?? "N/A")")
|
|
||||||
} else {
|
|
||||||
print("IDFA is not available or tracking authorization denied.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func fetchRemoteConfig() {
|
|
||||||
let localVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0"
|
|
||||||
print("version ------- \(localVersion)")
|
|
||||||
|
|
||||||
remoteConfig.fetch { [weak self] (status, error) in
|
|
||||||
guard let self = self else { return }
|
|
||||||
|
|
||||||
if status == .success {
|
|
||||||
self.retryAttempts = 0
|
|
||||||
print("Config fetched!")
|
|
||||||
self.remoteConfig.activate { changed, error in
|
|
||||||
if error == nil {
|
|
||||||
let js = self.remoteConfig.configValue(forKey: "isopen").jsonValue as! [String: Any]
|
|
||||||
let valueopen = js["isadopen"] as! Bool
|
|
||||||
let valueversion = js["version"] as! String
|
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
if valueversion == localVersion {
|
|
||||||
let appDelegate = UIApplication.shared.delegate
|
|
||||||
appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
|
|
||||||
StartManager.shared.superHero = false
|
|
||||||
} else {
|
|
||||||
if valueopen {
|
|
||||||
self.startAdCheck()
|
|
||||||
StartManager.shared.superHero = true
|
|
||||||
} else {
|
|
||||||
|
|
||||||
let appDelegate = UIApplication.shared.delegate
|
|
||||||
appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
|
|
||||||
StartManager.shared.superHero = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
print("Config not fetched")
|
|
||||||
if let error = error {
|
|
||||||
print("Error: \(error.localizedDescription)")
|
|
||||||
}
|
|
||||||
|
|
||||||
self.retryAttempts += 1
|
|
||||||
if self.retryAttempts <= self.maxRetryAttempts {
|
|
||||||
// 取消之前的定时器
|
|
||||||
self.retryTimer?.invalidate()
|
|
||||||
// 启动新的定时器
|
|
||||||
self.retryTimer = Timer.scheduledTimer(withTimeInterval: self.retryInterval, repeats: false) { [weak self] _ in
|
|
||||||
self?.fetchRemoteConfig()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
print("Max retry attempts reached. Stopping retries.")
|
|
||||||
let appDelegate = UIApplication.shared.delegate
|
|
||||||
appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///定时加载
|
|
||||||
func startAdCheck() {
|
|
||||||
createInterstitialAd()
|
|
||||||
adCheckStartTime = Date()
|
|
||||||
adCheckTimer = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(checkAdStatus), userInfo: nil, repeats: true)
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc func checkAdStatus() {
|
|
||||||
let elapsedTime = Date().timeIntervalSince(adCheckStartTime!)
|
|
||||||
let elapsedTimeInMilliseconds = Int(elapsedTime * 1000)
|
|
||||||
|
|
||||||
if interstitialAd.isReady {
|
|
||||||
interstitialAd.show()
|
|
||||||
adLoadTime = elapsedTimeInMilliseconds // 记录加载
|
|
||||||
adCheckTimer?.invalidate()
|
|
||||||
self.activityView.stopAnimating()
|
|
||||||
if StartManager.shared.idfaid == ""{
|
|
||||||
self.fetchIDFAUntilSuccess()
|
|
||||||
}else{
|
|
||||||
self.setPostSHOW()
|
|
||||||
}
|
|
||||||
} else if elapsedTimeInMilliseconds >= 10000 { // 10000 毫秒 = 10 秒
|
|
||||||
adCheckTimer?.invalidate()
|
|
||||||
let appDelegate = UIApplication.shared.delegate
|
|
||||||
appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
|
|
||||||
|
|
||||||
self.activityView.stopAnimating()
|
|
||||||
|
|
||||||
} else {
|
|
||||||
print("广告未准备好,继续检查...")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func setPostload(){
|
|
||||||
let url = "http://111.9.47.226:38080/top_selection/save_ad_load_log"
|
|
||||||
let parameters:[String : Any] = [
|
|
||||||
"deviceId": StartManager.shared.devicID ?? "",
|
|
||||||
"localIp": StartManager.shared.localIP ?? "",
|
|
||||||
"remoteIp": StartManager.shared.publicIP ?? "",
|
|
||||||
"linkId": "",
|
|
||||||
"packageName": "com.countdown.day.daycount",
|
|
||||||
"gaid": StartManager.shared.idfaid ?? "",
|
|
||||||
"dataId": "",
|
|
||||||
"shelfNumber":"开屏加载",
|
|
||||||
"succeed": StartManager.shared.succeed,
|
|
||||||
"loadTime":StartManager.shared.loadTime ?? "",
|
|
||||||
"adPlatform": StartManager.shared.adPlatform ?? "",
|
|
||||||
"countryCode": StartManager.shared.countryCode ?? "",
|
|
||||||
"adId": StartManager.shared.adId ?? "",
|
|
||||||
"platformResponseTime": StartManager.shared.platformResponseTime ?? "",
|
|
||||||
"getIpResponseTime": StartManager.shared.getIpResponseTime ?? "",
|
|
||||||
"ecpm": StartManager.shared.ecpm ?? "",
|
|
||||||
"dsp": StartManager.shared.dsp ?? "",
|
|
||||||
"network": StartManager.shared.network ?? "",
|
|
||||||
"showStatus": 0,
|
|
||||||
"washParam": true,
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
let headers: HTTPHeaders = [
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
]
|
|
||||||
|
|
||||||
NetworkManager.shared.postRequest(url: url, parameters: parameters, headers: headers) { result in
|
|
||||||
switch result {
|
|
||||||
case .success(let data):
|
|
||||||
print("Response:--- \(data)")
|
|
||||||
case .failure(let error):
|
|
||||||
print("Error:--- \(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func setPostSHOW(){
|
|
||||||
let url = "http://111.9.47.226:38080/top_selection/save_ad_show_log"
|
|
||||||
let parameters:[String : Any] = [
|
|
||||||
"deviceId": StartManager.shared.devicID ?? "",
|
|
||||||
"localIp": StartManager.shared.localIP ?? "",
|
|
||||||
"remoteIp": StartManager.shared.publicIP ?? "",
|
|
||||||
"linkId": "",
|
|
||||||
"packageName": "com.countdown.day.daycount",
|
|
||||||
"gaid": StartManager.shared.idfaid ?? "",
|
|
||||||
"dataId": "",
|
|
||||||
"shelfNumber":"开屏展示",
|
|
||||||
"succeed": StartManager.shared.succeed,
|
|
||||||
"loadTime":StartManager.shared.loadTime ?? "",
|
|
||||||
"adPlatform": StartManager.shared.adPlatform ?? "",
|
|
||||||
"countryCode": StartManager.shared.countryCode ?? "",
|
|
||||||
"adId": StartManager.shared.adId ?? "",
|
|
||||||
"platformResponseTime": StartManager.shared.platformResponseTime ?? "",
|
|
||||||
"getIpResponseTime": StartManager.shared.getIpResponseTime ?? "",
|
|
||||||
"ecpm": StartManager.shared.ecpm ?? "",
|
|
||||||
"dsp": StartManager.shared.dsp ?? "",
|
|
||||||
"network": StartManager.shared.network ?? "",
|
|
||||||
]
|
|
||||||
|
|
||||||
let headers: HTTPHeaders = [
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
]
|
|
||||||
|
|
||||||
NetworkManager.shared.postRequest(url: url, parameters: parameters, headers: headers) { result in
|
|
||||||
switch result {
|
|
||||||
case .success(let data):
|
|
||||||
print("Response:--- \(data)")
|
|
||||||
case .failure(let error):
|
|
||||||
print("Error:--- \(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func fetchIDFAUntilSuccess() {
|
|
||||||
DispatchQueue.global(qos: .background).async {
|
|
||||||
var idfaObtained = false
|
|
||||||
|
|
||||||
while !idfaObtained {
|
|
||||||
let semaphore = DispatchSemaphore(value: 0)
|
|
||||||
|
|
||||||
requestIDFA { idfa in
|
|
||||||
if let idfa = idfa {
|
|
||||||
print("Got IDFA: \(idfa)")
|
|
||||||
// 执行成功获取 IDFA 后的处理方法
|
|
||||||
// self.performActionWithIDFA(idfa)
|
|
||||||
StartManager.shared.idfaid = idfa
|
|
||||||
self.setPostSHOW()
|
|
||||||
idfaObtained = true
|
|
||||||
} else {
|
|
||||||
print("Failed to get IDFA, retrying...")
|
|
||||||
DispatchQueue.global(qos: .background).asyncAfter(deadline: .now() + 1.0) {
|
|
||||||
semaphore.signal()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
semaphore.wait()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
extension AV_LaunchLimitesVC: MAAdDelegate
|
|
||||||
{
|
|
||||||
func createInterstitialAd() {
|
|
||||||
|
|
||||||
let randomString = getRandomString()
|
|
||||||
|
|
||||||
if StartManager.shared.adId == nil{
|
|
||||||
StartManager.shared.adId = randomString ?? "bee9f7039e56cc7a"
|
|
||||||
interstitialAd = MAInterstitialAd(adUnitIdentifier: StartManager.shared.adId!)
|
|
||||||
print("adid-----\(StartManager.shared.adId ?? "gggg")")
|
|
||||||
}else{
|
|
||||||
interstitialAd = MAInterstitialAd(adUnitIdentifier: StartManager.shared.adId!)
|
|
||||||
print("adid-----\(StartManager.shared.adId ?? "gggg")")
|
|
||||||
}
|
|
||||||
|
|
||||||
interstitialAd.delegate = self
|
|
||||||
self.idad = randomString
|
|
||||||
|
|
||||||
// Load the first ad
|
|
||||||
interstitialAd.load()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// MARK: MAAdDelegate Protocol
|
|
||||||
|
|
||||||
/// 当广告加载成功时调用的方法
|
|
||||||
func didLoad(_ ad: MAAd) {
|
|
||||||
// 重试尝试次数重置为0
|
|
||||||
retryAttempt = 0
|
|
||||||
// 记录广告加载成功的相关信息
|
|
||||||
// StartManager.shared.shelfNumber = "开屏加载"
|
|
||||||
StartManager.shared.succeed = true
|
|
||||||
StartManager.shared.loadTime = self.adLoadTime
|
|
||||||
StartManager.shared.adPlatform = "MAX"
|
|
||||||
StartManager.shared.countryCode = ALSdk.shared().configuration.countryCode
|
|
||||||
StartManager.shared.adId = self.idad
|
|
||||||
StartManager.shared.platformResponseTime = ad.requestLatency
|
|
||||||
StartManager.shared.ecpm = Float(ad.revenue)
|
|
||||||
StartManager.shared.dsp = ad.dspName
|
|
||||||
StartManager.shared.network = ad.networkName
|
|
||||||
|
|
||||||
self.setPostload()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 当广告加载失败时调用的方法
|
|
||||||
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError) {
|
|
||||||
// 广告加载失败,建议进行重试
|
|
||||||
// 使用指数递增的延迟时间进行重试,最大延迟时间为 64 秒
|
|
||||||
retryAttempt += 1
|
|
||||||
let delaySec = pow(2.0, min(6.0, retryAttempt))
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + delaySec) {
|
|
||||||
self.interstitialAd.load()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 当广告显示时调用的方法
|
|
||||||
func didDisplay(_ ad: MAAd) {
|
|
||||||
// 暂停您的应用的背景音频
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 当用户点击广告时调用的方法
|
|
||||||
func didClick(_ ad: MAAd) {
|
|
||||||
// 用户点击广告
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 当广告隐藏时调用的方法
|
|
||||||
func didHide(_ ad: MAAd) {
|
|
||||||
// 恢复您的应用的背景音频
|
|
||||||
// 广告隐藏后,预加载下一个广告
|
|
||||||
interstitialAd.load()
|
|
||||||
let appDelegate = UIApplication.shared.delegate
|
|
||||||
appDelegate?.window??.rootViewController = AV_NAVVC(rootViewController: AV_WaterHomeVC())
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// 当广告无法显示时调用的方法
|
|
||||||
func didFail(toDisplay ad: MAAd, withError error: MAError) {
|
|
||||||
// 广告无法显示,建议加载下一个广告
|
|
||||||
interstitialAd.load()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@ -7,8 +7,7 @@
|
|||||||
|
|
||||||
import UIKit
|
import UIKit
|
||||||
import FSCalendar
|
import FSCalendar
|
||||||
//import FirebaseAnalytics
|
|
||||||
import AppLovinSDK
|
|
||||||
import Alamofire
|
import Alamofire
|
||||||
import FirebaseRemoteConfig
|
import FirebaseRemoteConfig
|
||||||
|
|
||||||
@ -28,9 +27,7 @@ class AV_MineVC: AV_RootVC {
|
|||||||
|
|
||||||
@IBOutlet weak var noneImagV: UIImageView!
|
@IBOutlet weak var noneImagV: UIImageView!
|
||||||
|
|
||||||
var interstitialAd: MAInterstitialAd!
|
|
||||||
var remoteConfig: RemoteConfig!
|
|
||||||
var isadshow:Bool = false
|
|
||||||
var retryAttempt = 0.0
|
var retryAttempt = 0.0
|
||||||
|
|
||||||
var arr = [UserModel]()
|
var arr = [UserModel]()
|
||||||
@ -91,38 +88,16 @@ class AV_MineVC: AV_RootVC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc func back(){
|
@objc func back(){
|
||||||
// navigationController?.popViewController(animated: true)
|
|
||||||
if self.isadshow == true{
|
LuxADManager.shareInstance().showADByRandomMode(callback: {
|
||||||
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.5) {
|
actionType in
|
||||||
|
|
||||||
if self.interstitialAd.isReady {
|
|
||||||
self.interstitialAd.show()
|
|
||||||
self.setPostSHOW()
|
|
||||||
|
|
||||||
}else{
|
|
||||||
self.navigationController?.popViewController(animated: true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
self.navigationController?.popViewController(animated: true)
|
self.navigationController?.popViewController(animated: true)
|
||||||
}
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
super.viewWillAppear(animated)
|
super.viewWillAppear(animated)
|
||||||
self.createInterstitialAd()
|
|
||||||
remoteConfig = RemoteConfig.remoteConfig()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 设置最小获取间隔(开发期间可以设置较小的值)
|
|
||||||
let settings = RemoteConfigSettings()
|
|
||||||
settings.minimumFetchInterval = 0
|
|
||||||
remoteConfig.configSettings = settings
|
|
||||||
// Fetch 配置值
|
|
||||||
remoteConfig.setDefaults(fromPlist: "isopen")
|
|
||||||
fetchRemoteConfig()
|
|
||||||
self.navigationController?.navigationBar.isHidden = false
|
self.navigationController?.navigationBar.isHidden = false
|
||||||
calendarV.reloadData()
|
calendarV.reloadData()
|
||||||
|
|
||||||
@ -191,123 +166,7 @@ class AV_MineVC: AV_RootVC {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///是否有广告
|
|
||||||
func fetchRemoteConfig() {
|
|
||||||
let localVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "0.0"
|
|
||||||
remoteConfig.fetch{ (status, error) -> Void in
|
|
||||||
if status == .success {
|
|
||||||
print("Config fetched!")
|
|
||||||
self.remoteConfig.activate { changed, error in
|
|
||||||
if error == nil{
|
|
||||||
let js = self.remoteConfig.configValue(forKey: "isopen").jsonValue as! [String:Any]
|
|
||||||
let valueopen = js["isadopen"] as! Bool
|
|
||||||
let valueversion = js["version"] as! String
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
if valueversion == localVersion{
|
|
||||||
self.isadshow = false
|
|
||||||
}else{
|
|
||||||
if valueopen {
|
|
||||||
self.isadshow = true
|
|
||||||
} else {
|
|
||||||
self.isadshow = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
print("Config not fetched")
|
|
||||||
if let error = error {
|
|
||||||
print("Error: \(error.localizedDescription)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
func setPostload(){
|
|
||||||
let url = "http://111.9.47.226:38080/top_selection/save_ad_load_log"
|
|
||||||
let parameters:[String : Any] = [
|
|
||||||
"deviceId": StartManager.shared.devicID ?? "",
|
|
||||||
"localIp": StartManager.shared.localIP ?? "",
|
|
||||||
"remoteIp": StartManager.shared.publicIP ?? "",
|
|
||||||
"linkId": "",
|
|
||||||
"packageName": "com.countdown.day.daycount",
|
|
||||||
"gaid": StartManager.shared.idfaid ?? "",
|
|
||||||
"dataId": "",
|
|
||||||
"shelfNumber":"日历页返回",
|
|
||||||
"succeed": StartManager.shared.succeed,
|
|
||||||
"loadTime": "",
|
|
||||||
"adPlatform": StartManager.shared.adPlatform ?? "",
|
|
||||||
"countryCode": StartManager.shared.countryCode ?? "",
|
|
||||||
"adId": StartManager.shared.adId ?? "",
|
|
||||||
"platformResponseTime": StartManager.shared.platformResponseTime ?? "",
|
|
||||||
"getIpResponseTime": StartManager.shared.getIpResponseTime ?? "",
|
|
||||||
"ecpm": StartManager.shared.ecpm ?? "",
|
|
||||||
"dsp": StartManager.shared.dsp ?? "",
|
|
||||||
"network": StartManager.shared.network ?? "",
|
|
||||||
"showStatus": 0,
|
|
||||||
"washParam": true,
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
let headers: HTTPHeaders = [
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
]
|
|
||||||
|
|
||||||
NetworkManager.shared.postRequest(url: url, parameters: parameters, headers: headers) { result in
|
|
||||||
switch result {
|
|
||||||
case .success(let data):
|
|
||||||
print("Response:--- \(data)")
|
|
||||||
case .failure(let error):
|
|
||||||
print("Error:--- \(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func setPostSHOW(){
|
|
||||||
let url = "http://111.9.47.226:38080/top_selection/save_ad_show_log"
|
|
||||||
let parameters:[String : Any] = [
|
|
||||||
"deviceId": StartManager.shared.devicID ?? "",
|
|
||||||
"localIp": StartManager.shared.localIP ?? "",
|
|
||||||
"remoteIp": StartManager.shared.publicIP ?? "",
|
|
||||||
"linkId": "",
|
|
||||||
"packageName": "com.countdown.day.daycount",
|
|
||||||
"gaid": StartManager.shared.idfaid ?? "",
|
|
||||||
"dataId": "",
|
|
||||||
"shelfNumber":"日历页返回",
|
|
||||||
"succeed": StartManager.shared.succeed,
|
|
||||||
"loadTime": "",
|
|
||||||
"adPlatform": StartManager.shared.adPlatform ?? "",
|
|
||||||
"countryCode": StartManager.shared.countryCode ?? "",
|
|
||||||
"adId": StartManager.shared.adId ?? "",
|
|
||||||
"platformResponseTime": StartManager.shared.platformResponseTime ?? "",
|
|
||||||
"getIpResponseTime": StartManager.shared.getIpResponseTime ?? "",
|
|
||||||
"ecpm": StartManager.shared.ecpm ?? "",
|
|
||||||
"dsp": StartManager.shared.dsp ?? "",
|
|
||||||
"network": StartManager.shared.network ?? "",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
let headers: HTTPHeaders = [
|
|
||||||
"Content-Type": "application/json"
|
|
||||||
]
|
|
||||||
|
|
||||||
NetworkManager.shared.postRequest(url: url, parameters: parameters, headers: headers) { result in
|
|
||||||
switch result {
|
|
||||||
case .success(let data):
|
|
||||||
print("Response:--- \(data)")
|
|
||||||
case .failure(let error):
|
|
||||||
print("Error:--- \(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,71 +261,3 @@ extension UIView {
|
|||||||
layer.mask = maskLayer
|
layer.mask = maskLayer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
extension AV_MineVC: MAAdDelegate
|
|
||||||
{
|
|
||||||
func createInterstitialAd()
|
|
||||||
{
|
|
||||||
let randomString = getRandomString()
|
|
||||||
interstitialAd = MAInterstitialAd(adUnitIdentifier: randomString ?? "bee9f7039e56cc7a")
|
|
||||||
interstitialAd.delegate = self
|
|
||||||
|
|
||||||
// Load the first ad
|
|
||||||
interstitialAd.load()
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: MAAdDelegate Protocol
|
|
||||||
|
|
||||||
func didLoad(_ ad: MAAd)
|
|
||||||
{
|
|
||||||
// Interstitial ad is ready to be shown. 'interstitialAd.isReady' will now return 'true'
|
|
||||||
|
|
||||||
// Reset retry attempt
|
|
||||||
retryAttempt = 0
|
|
||||||
StartManager.shared.succeed = true
|
|
||||||
// StartManager.shared.loadTime = self.adLoadTime
|
|
||||||
StartManager.shared.adPlatform = "MAX"
|
|
||||||
StartManager.shared.countryCode = ALSdk.shared().configuration.countryCode
|
|
||||||
StartManager.shared.adId = "bee9f7039e56cc7a"
|
|
||||||
StartManager.shared.platformResponseTime = ad.requestLatency
|
|
||||||
StartManager.shared.ecpm = Float(ad.revenue)
|
|
||||||
StartManager.shared.dsp = ad.dspName
|
|
||||||
StartManager.shared.network = ad.networkName
|
|
||||||
|
|
||||||
|
|
||||||
setPostload()
|
|
||||||
}
|
|
||||||
|
|
||||||
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError)
|
|
||||||
{
|
|
||||||
// Interstitial ad failed to load
|
|
||||||
// We recommend retrying with exponentially higher delays up to a maximum delay (in this case 64 seconds)
|
|
||||||
|
|
||||||
retryAttempt += 1
|
|
||||||
let delaySec = pow(2.0, min(6.0, retryAttempt))
|
|
||||||
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + delaySec) {
|
|
||||||
self.interstitialAd.load()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func didDisplay(_ ad: MAAd)
|
|
||||||
{
|
|
||||||
// Pause your app's background audio
|
|
||||||
}
|
|
||||||
|
|
||||||
func didClick(_ ad: MAAd) {}
|
|
||||||
|
|
||||||
func didHide(_ ad: MAAd)
|
|
||||||
{
|
|
||||||
// Resume your app's background audio
|
|
||||||
// Interstitial ad is hidden. Pre-load the next ad
|
|
||||||
interstitialAd.load()
|
|
||||||
self.navigationController?.popViewController(animated: true)
|
|
||||||
}
|
|
||||||
|
|
||||||
func didFail(toDisplay ad: MAAd, withError error: MAError)
|
|
||||||
{
|
|
||||||
// Interstitial ad failed to display. We recommend loading the next ad
|
|
||||||
interstitialAd.load()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user