封装网络请求接口
This commit is contained in:
parent
49cc5b5417
commit
92b5a7c917
@ -7,6 +7,7 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
753B789E2C4FB1450007526F /* adNetWork.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753B789D2C4FB1450007526F /* adNetWork.swift */; };
|
||||||
753C258A2C3B8272006E2660 /* AV_WaterDayCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 753C25892C3B8272006E2660 /* AV_WaterDayCell.xib */; };
|
753C258A2C3B8272006E2660 /* AV_WaterDayCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 753C25892C3B8272006E2660 /* AV_WaterDayCell.xib */; };
|
||||||
753C258B2C3B8272006E2660 /* AV_WaterDayCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753C25882C3B8272006E2660 /* AV_WaterDayCell.swift */; };
|
753C258B2C3B8272006E2660 /* AV_WaterDayCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 753C25882C3B8272006E2660 /* AV_WaterDayCell.swift */; };
|
||||||
753C258E2C3B88F4006E2660 /* AV_BirtherDayTaskCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 753C258D2C3B88F4006E2660 /* AV_BirtherDayTaskCell.xib */; };
|
753C258E2C3B88F4006E2660 /* AV_BirtherDayTaskCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 753C258D2C3B88F4006E2660 /* AV_BirtherDayTaskCell.xib */; };
|
||||||
@ -82,8 +83,6 @@
|
|||||||
75F3F3DB2C4CE5F600005A7E /* AV_MinePlayerVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 75F3F3D92C4CE5F600005A7E /* AV_MinePlayerVC.xib */; };
|
75F3F3DB2C4CE5F600005A7E /* AV_MinePlayerVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 75F3F3D92C4CE5F600005A7E /* AV_MinePlayerVC.xib */; };
|
||||||
75F3F3DE2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F3F3DC2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.swift */; };
|
75F3F3DE2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F3F3DC2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.swift */; };
|
||||||
75F3F3DF2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 75F3F3DD2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.xib */; };
|
75F3F3DF2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 75F3F3DD2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.xib */; };
|
||||||
75F3F3E22C4CE81800005A7E /* AV_EditPlayerVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F3F3E02C4CE81800005A7E /* AV_EditPlayerVC.swift */; };
|
|
||||||
75F3F3E32C4CE81800005A7E /* AV_EditPlayerVC.xib in Resources */ = {isa = PBXBuildFile; fileRef = 75F3F3E12C4CE81800005A7E /* AV_EditPlayerVC.xib */; };
|
|
||||||
75FAEF2E2C3E5D9800298C7D /* CircularProgressBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75FAEF2D2C3E5D9700298C7D /* CircularProgressBarView.swift */; };
|
75FAEF2E2C3E5D9800298C7D /* CircularProgressBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75FAEF2D2C3E5D9700298C7D /* CircularProgressBarView.swift */; };
|
||||||
75FAEF312C3E735800298C7D /* HealthManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75FAEF302C3E735800298C7D /* HealthManager.swift */; };
|
75FAEF312C3E735800298C7D /* HealthManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75FAEF302C3E735800298C7D /* HealthManager.swift */; };
|
||||||
75FAEF342C3E8D7400298C7D /* AV_NoneCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75FAEF322C3E8D7400298C7D /* AV_NoneCell.swift */; };
|
75FAEF342C3E8D7400298C7D /* AV_NoneCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75FAEF322C3E8D7400298C7D /* AV_NoneCell.swift */; };
|
||||||
@ -118,6 +117,7 @@
|
|||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
54C12C891A8D806F1F2D9570 /* Pods_anniversary_Project.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_anniversary_Project.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
54C12C891A8D806F1F2D9570 /* Pods_anniversary_Project.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_anniversary_Project.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
753B789D2C4FB1450007526F /* adNetWork.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = adNetWork.swift; sourceTree = "<group>"; };
|
||||||
753C25882C3B8272006E2660 /* AV_WaterDayCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AV_WaterDayCell.swift; sourceTree = "<group>"; };
|
753C25882C3B8272006E2660 /* AV_WaterDayCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AV_WaterDayCell.swift; sourceTree = "<group>"; };
|
||||||
753C25892C3B8272006E2660 /* AV_WaterDayCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AV_WaterDayCell.xib; sourceTree = "<group>"; };
|
753C25892C3B8272006E2660 /* AV_WaterDayCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AV_WaterDayCell.xib; sourceTree = "<group>"; };
|
||||||
753C258C2C3B88F4006E2660 /* AV_BirtherDayTaskCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AV_BirtherDayTaskCell.swift; sourceTree = "<group>"; };
|
753C258C2C3B88F4006E2660 /* AV_BirtherDayTaskCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AV_BirtherDayTaskCell.swift; sourceTree = "<group>"; };
|
||||||
@ -198,8 +198,6 @@
|
|||||||
75F3F3D92C4CE5F600005A7E /* AV_MinePlayerVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AV_MinePlayerVC.xib; sourceTree = "<group>"; };
|
75F3F3D92C4CE5F600005A7E /* AV_MinePlayerVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AV_MinePlayerVC.xib; sourceTree = "<group>"; };
|
||||||
75F3F3DC2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AV_WaterKeyBordPlayerVC.swift; sourceTree = "<group>"; };
|
75F3F3DC2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AV_WaterKeyBordPlayerVC.swift; sourceTree = "<group>"; };
|
||||||
75F3F3DD2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AV_WaterKeyBordPlayerVC.xib; sourceTree = "<group>"; };
|
75F3F3DD2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AV_WaterKeyBordPlayerVC.xib; sourceTree = "<group>"; };
|
||||||
75F3F3E02C4CE81800005A7E /* AV_EditPlayerVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AV_EditPlayerVC.swift; sourceTree = "<group>"; };
|
|
||||||
75F3F3E12C4CE81800005A7E /* AV_EditPlayerVC.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = AV_EditPlayerVC.xib; sourceTree = "<group>"; };
|
|
||||||
75FAEF2D2C3E5D9700298C7D /* CircularProgressBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularProgressBarView.swift; sourceTree = "<group>"; };
|
75FAEF2D2C3E5D9700298C7D /* CircularProgressBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularProgressBarView.swift; sourceTree = "<group>"; };
|
||||||
75FAEF2F2C3E723A00298C7D /* anniversary_Project.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = anniversary_Project.entitlements; sourceTree = "<group>"; };
|
75FAEF2F2C3E723A00298C7D /* anniversary_Project.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = anniversary_Project.entitlements; sourceTree = "<group>"; };
|
||||||
75FAEF302C3E735800298C7D /* HealthManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HealthManager.swift; sourceTree = "<group>"; };
|
75FAEF302C3E735800298C7D /* HealthManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HealthManager.swift; sourceTree = "<group>"; };
|
||||||
@ -251,6 +249,14 @@
|
|||||||
name = Frameworks;
|
name = Frameworks;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
753B789C2C4FB1330007526F /* ADopen */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
753B789D2C4FB1450007526F /* adNetWork.swift */,
|
||||||
|
);
|
||||||
|
path = ADopen;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
753C259C2C3BED13006E2660 /* homewater */ = {
|
753C259C2C3BED13006E2660 /* homewater */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -314,13 +320,6 @@
|
|||||||
path = V;
|
path = V;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
75B426902C4DF69C001844C2 /* NetWork */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
);
|
|
||||||
path = NetWork;
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
75C0A1252BC787A400AB0094 = {
|
75C0A1252BC787A400AB0094 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -442,7 +441,7 @@
|
|||||||
75C0A1742BC78F2500AB0094 /* Tool */ = {
|
75C0A1742BC78F2500AB0094 /* Tool */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
75B426902C4DF69C001844C2 /* NetWork */,
|
753B789C2C4FB1330007526F /* ADopen */,
|
||||||
753C25A12C3BF4A1006E2660 /* MLSliderRulerScrollView.swift */,
|
753C25A12C3BF4A1006E2660 /* MLSliderRulerScrollView.swift */,
|
||||||
753C25A02C3BF4A1006E2660 /* MLSliderRulerView.swift */,
|
753C25A02C3BF4A1006E2660 /* MLSliderRulerView.swift */,
|
||||||
753C25902C3BBA9D006E2660 /* AV_WaveView.swift */,
|
753C25902C3BBA9D006E2660 /* AV_WaveView.swift */,
|
||||||
@ -539,8 +538,6 @@
|
|||||||
75F3F3D92C4CE5F600005A7E /* AV_MinePlayerVC.xib */,
|
75F3F3D92C4CE5F600005A7E /* AV_MinePlayerVC.xib */,
|
||||||
75F3F3DC2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.swift */,
|
75F3F3DC2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.swift */,
|
||||||
75F3F3DD2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.xib */,
|
75F3F3DD2C4CE6F400005A7E /* AV_WaterKeyBordPlayerVC.xib */,
|
||||||
75F3F3E02C4CE81800005A7E /* AV_EditPlayerVC.swift */,
|
|
||||||
75F3F3E12C4CE81800005A7E /* AV_EditPlayerVC.xib */,
|
|
||||||
);
|
);
|
||||||
path = Player;
|
path = Player;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -691,7 +688,6 @@
|
|||||||
75C4E0B82C367EAE00B4C170 /* AV_WaterCell.xib in Resources */,
|
75C4E0B82C367EAE00B4C170 /* AV_WaterCell.xib in Resources */,
|
||||||
753C258E2C3B88F4006E2660 /* AV_BirtherDayTaskCell.xib in Resources */,
|
753C258E2C3B88F4006E2660 /* AV_BirtherDayTaskCell.xib in Resources */,
|
||||||
75C0A1F52BCCD48A00AB0094 /* AV_TaskCell.xib in Resources */,
|
75C0A1F52BCCD48A00AB0094 /* AV_TaskCell.xib in Resources */,
|
||||||
75F3F3E32C4CE81800005A7E /* AV_EditPlayerVC.xib in Resources */,
|
|
||||||
753C25962C3BE9D5006E2660 /* AV_AddWaterVC.xib in Resources */,
|
753C25962C3BE9D5006E2660 /* AV_AddWaterVC.xib in Resources */,
|
||||||
75FDC0B42BCE1F4F005B3D13 /* AV_CalenDarcell.xib in Resources */,
|
75FDC0B42BCE1F4F005B3D13 /* AV_CalenDarcell.xib in Resources */,
|
||||||
75C0A16D2BC789F900AB0094 /* AV_HomeVC.xib in Resources */,
|
75C0A16D2BC789F900AB0094 /* AV_HomeVC.xib in Resources */,
|
||||||
@ -803,6 +799,7 @@
|
|||||||
759616702C35348A00363C46 /* AV_SportsVC.swift in Sources */,
|
759616702C35348A00363C46 /* AV_SportsVC.swift in Sources */,
|
||||||
75C0A1EA2BCCC83D00AB0094 /* AV_CustomTabBar.swift in Sources */,
|
75C0A1EA2BCCC83D00AB0094 /* AV_CustomTabBar.swift in Sources */,
|
||||||
75FAEF342C3E8D7400298C7D /* AV_NoneCell.swift in Sources */,
|
75FAEF342C3E8D7400298C7D /* AV_NoneCell.swift in Sources */,
|
||||||
|
753B789E2C4FB1450007526F /* adNetWork.swift in Sources */,
|
||||||
75FDC0C82BCF77B7005B3D13 /* AV_AboutVC.swift in Sources */,
|
75FDC0C82BCF77B7005B3D13 /* AV_AboutVC.swift in Sources */,
|
||||||
75FAEF312C3E735800298C7D /* HealthManager.swift in Sources */,
|
75FAEF312C3E735800298C7D /* HealthManager.swift in Sources */,
|
||||||
754835032C3D04F300AC6F8F /* AV_WaterSettingVC.swift in Sources */,
|
754835032C3D04F300AC6F8F /* AV_WaterSettingVC.swift in Sources */,
|
||||||
@ -831,7 +828,6 @@
|
|||||||
754C97E22C3D453800A0455D /* AV_pagesAllVC.swift in Sources */,
|
754C97E22C3D453800A0455D /* AV_pagesAllVC.swift in Sources */,
|
||||||
75C0A1762BC78F3300AB0094 /* WCDB.swift in Sources */,
|
75C0A1762BC78F3300AB0094 /* WCDB.swift in Sources */,
|
||||||
754C97DE2C3D2EAA00A0455D /* AV_TemperatureVC.swift in Sources */,
|
754C97DE2C3D2EAA00A0455D /* AV_TemperatureVC.swift in Sources */,
|
||||||
75F3F3E22C4CE81800005A7E /* AV_EditPlayerVC.swift in Sources */,
|
|
||||||
754C97D22C3D0F7100A0455D /* AV_selectWeightVC.swift in Sources */,
|
754C97D22C3D0F7100A0455D /* AV_selectWeightVC.swift in Sources */,
|
||||||
753C259F2C3BEFB8006E2660 /* AV_ScrollingScaleView.swift in Sources */,
|
753C259F2C3BEFB8006E2660 /* AV_ScrollingScaleView.swift in Sources */,
|
||||||
753C25A22C3BF4A1006E2660 /* MLSliderRulerView.swift in Sources */,
|
753C25A22C3BF4A1006E2660 /* MLSliderRulerView.swift in Sources */,
|
||||||
|
|||||||
@ -53,7 +53,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// self.window?.rootViewController = AV_NAVVC(rootViewController: vc)
|
// self.window?.rootViewController = AV_NAVVC(rootViewController: vc)
|
||||||
} else {
|
} else {
|
||||||
// 第一次启动
|
// 第一次启动
|
||||||
@ -70,7 +69,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDe
|
|||||||
|
|
||||||
ALSdk.shared().initialize(with: initConfig) { sdkConfig in
|
ALSdk.shared().initialize(with: initConfig) { sdkConfig in
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -127,7 +125,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDe
|
|||||||
print("相册权限已拒绝或受限,请在设置中开启权限")
|
print("相册权限已拒绝或受限,请在设置中开启权限")
|
||||||
case .notDetermined:
|
case .notDetermined:
|
||||||
// 用户尚未作出选择,请求相册权限
|
// 用户尚未作出选择,请求相册权限
|
||||||
PHPhotoLibrary.requestAuthorization { [weak self] (newStatus) in
|
PHPhotoLibrary.requestAuthorization { (newStatus) in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if newStatus == .authorized {
|
if newStatus == .authorized {
|
||||||
// 用户授权访问相册
|
// 用户授权访问相册
|
||||||
@ -138,6 +136,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case .limited:
|
||||||
|
print("用户已授权此应用程序访问有限的照片库")
|
||||||
@unknown default:
|
@unknown default:
|
||||||
// 处理未知权限状态
|
// 处理未知权限状态
|
||||||
print("未知的相册权限状态")
|
print("未知的相册权限状态")
|
||||||
|
|||||||
@ -39,11 +39,7 @@ class AV_WaterHomeVC: AV_RootVC {
|
|||||||
print("IDFA is not available or tracking authorization denied.")
|
print("IDFA is not available or tracking authorization denied.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setPostStar()
|
setPostStar()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func setPostStar(){
|
func setPostStar(){
|
||||||
|
|||||||
@ -9,6 +9,9 @@ import UIKit
|
|||||||
|
|
||||||
class AV_WaterSettingVC: AV_RootVC {
|
class AV_WaterSettingVC: AV_RootVC {
|
||||||
|
|
||||||
|
@IBOutlet weak var sersionV: UIView!
|
||||||
|
|
||||||
|
|
||||||
@IBOutlet weak var waterprogressView: UIView!
|
@IBOutlet weak var waterprogressView: UIView!
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +39,7 @@ class AV_WaterSettingVC: AV_RootVC {
|
|||||||
var timer: Timer?
|
var timer: Timer?
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
sersionV.layer.cornerRadius = 28
|
||||||
|
|
||||||
waterbgView.layer.cornerRadius = 28
|
waterbgView.layer.cornerRadius = 28
|
||||||
clockView.layer.cornerRadius = 28
|
clockView.layer.cornerRadius = 28
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
<outlet property="clockView" destination="TIW-zC-f9J" id="oqz-Jx-see"/>
|
<outlet property="clockView" destination="TIW-zC-f9J" id="oqz-Jx-see"/>
|
||||||
<outlet property="drinkLabel" destination="MLy-Ke-6jm" id="g3U-52-NQe"/>
|
<outlet property="drinkLabel" destination="MLy-Ke-6jm" id="g3U-52-NQe"/>
|
||||||
<outlet property="privaCyView" destination="12a-0R-fmU" id="TPf-oP-6J6"/>
|
<outlet property="privaCyView" destination="12a-0R-fmU" id="TPf-oP-6J6"/>
|
||||||
|
<outlet property="sersionV" destination="Jqr-oB-xH3" id="aku-lR-sBH"/>
|
||||||
<outlet property="targetLabel" destination="ntq-dK-8e2" id="8bm-oW-Oxu"/>
|
<outlet property="targetLabel" destination="ntq-dK-8e2" id="8bm-oW-Oxu"/>
|
||||||
<outlet property="userView" destination="Lqf-cr-lF5" id="jmM-u2-fek"/>
|
<outlet property="userView" destination="Lqf-cr-lF5" id="jmM-u2-fek"/>
|
||||||
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
|
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import FirebaseRemoteConfig
|
|||||||
|
|
||||||
|
|
||||||
class AV_AddPlayerVC: AV_RootVC {
|
class AV_AddPlayerVC: AV_RootVC {
|
||||||
|
|
||||||
var retryAttempt = 0.0
|
var retryAttempt = 0.0
|
||||||
var interstitialAd: MAInterstitialAd!
|
var interstitialAd: MAInterstitialAd!
|
||||||
var adCheckTimer: Timer?
|
var adCheckTimer: Timer?
|
||||||
@ -23,7 +23,7 @@ class AV_AddPlayerVC: AV_RootVC {
|
|||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
startAdCheck()
|
startAdCheck()
|
||||||
}
|
}
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
@ -33,7 +33,7 @@ class AV_AddPlayerVC: AV_RootVC {
|
|||||||
}
|
}
|
||||||
///定时加载
|
///定时加载
|
||||||
func startAdCheck() {
|
func startAdCheck() {
|
||||||
|
|
||||||
adCheckStartTime = Date()
|
adCheckStartTime = Date()
|
||||||
adCheckTimer = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(checkAdStatus), userInfo: nil, repeats: true)
|
adCheckTimer = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(checkAdStatus), userInfo: nil, repeats: true)
|
||||||
}
|
}
|
||||||
@ -46,7 +46,8 @@ class AV_AddPlayerVC: AV_RootVC {
|
|||||||
interstitialAd.show()
|
interstitialAd.show()
|
||||||
adLoadTime = elapsedTimeInMilliseconds // 记录加载
|
adLoadTime = elapsedTimeInMilliseconds // 记录加载
|
||||||
adCheckTimer?.invalidate()
|
adCheckTimer?.invalidate()
|
||||||
setshow()
|
setShow()
|
||||||
|
|
||||||
} else if elapsedTimeInMilliseconds >= 10000 { // 10000 毫秒 = 10 秒
|
} else if elapsedTimeInMilliseconds >= 10000 { // 10000 毫秒 = 10 秒
|
||||||
adCheckTimer?.invalidate()
|
adCheckTimer?.invalidate()
|
||||||
self.navigationController?.popViewController(animated: true)
|
self.navigationController?.popViewController(animated: true)
|
||||||
@ -55,7 +56,7 @@ class AV_AddPlayerVC: AV_RootVC {
|
|||||||
print("广告未准备好,继续检查...")
|
print("广告未准备好,继续检查...")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setPostload(){
|
func setPostload(){
|
||||||
let url = "http://111.9.47.226:38080/top_selection/save_ad_load_log"
|
let url = "http://111.9.47.226:38080/top_selection/save_ad_load_log"
|
||||||
let parameters:[String : Any] = [
|
let parameters:[String : Any] = [
|
||||||
@ -130,6 +131,7 @@ class AV_AddPlayerVC: AV_RootVC {
|
|||||||
switch result {
|
switch result {
|
||||||
case .success(let data):
|
case .success(let data):
|
||||||
print("Response:--- \(data)")
|
print("Response:--- \(data)")
|
||||||
|
|
||||||
case .failure(let error):
|
case .failure(let error):
|
||||||
print("Error:--- \(error)")
|
print("Error:--- \(error)")
|
||||||
}
|
}
|
||||||
@ -137,26 +139,50 @@ class AV_AddPlayerVC: AV_RootVC {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func setshow(){
|
// func setshow(){
|
||||||
let parameters:[String : Any] = [
|
// let parameters:[String : Any] = [
|
||||||
"appid": "com.countdown.day.daycount",
|
// "appid": "com.countdown.day.daycount",
|
||||||
"idfa":StartManager.shared.idfaid ?? "",
|
// "idfa":StartManager.shared.idfaid ?? "",
|
||||||
"id":StartManager.shared.idOneAD,
|
// "id":StartManager.shared.idOneAD,
|
||||||
"ecpm":StartManager.shared.idOne ?? "",
|
// "ecpm":StartManager.shared.idOneprice ?? "",
|
||||||
|
//
|
||||||
]
|
// ]
|
||||||
NetworkManager.shared.postRequest(url: StartManager.shared.showurl, parameters: parameters, headers: StartManager.shared.headers) { result in
|
// NetworkManager.shared.postRequest(url: StartManager.shared.showurl, parameters: parameters, headers: StartManager.shared.headers) { result in
|
||||||
|
// switch result {
|
||||||
|
// case .success(let data):
|
||||||
|
// print("Response:--- \(data)")
|
||||||
|
// if let status = data["status"] as? String, status == "Success" {
|
||||||
|
// if let needLoad = data["close"] as? Int {
|
||||||
|
// let seconds = millisecondsToSeconds(milliseconds: needLoad)
|
||||||
|
//
|
||||||
|
// DispatchQueue.main.asyncAfter(wallDeadline: .now() + seconds) {
|
||||||
|
// closeADWindow()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// case .failure(let error):
|
||||||
|
// print("Error:--- \(error)")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
func setShow() {
|
||||||
|
let idfa = StartManager.shared.idfaid
|
||||||
|
let adId = StartManager.shared.idOneAD
|
||||||
|
let ecpm = StartManager.shared.idOneprice
|
||||||
|
|
||||||
|
AdLoader.shared.showAd(idfa: idfa, adId: adId, ecpm: ecpm) { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .success(let data):
|
case .success(let closeTime): break
|
||||||
print("Response:--- \(data)")
|
// let seconds = millisecondsToSeconds(milliseconds: closeTime)
|
||||||
|
// DispatchQueue.main.asyncAfter(deadline: .now() + seconds) {
|
||||||
|
// closeADWindow()
|
||||||
|
// }
|
||||||
case .failure(let error):
|
case .failure(let error):
|
||||||
print("Error:--- \(error)")
|
print("Error:--- \(error)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AV_AddPlayerVC: MAAdDelegate
|
extension AV_AddPlayerVC: MAAdDelegate
|
||||||
@ -191,7 +217,7 @@ extension AV_AddPlayerVC: MAAdDelegate
|
|||||||
StartManager.shared.network = ad.networkName
|
StartManager.shared.network = ad.networkName
|
||||||
|
|
||||||
|
|
||||||
StartManager.shared.idOne = Float(ad.revenue)
|
StartManager.shared.idOneprice = Float(ad.revenue)
|
||||||
print("----idOne\(Float(ad.revenue))")
|
print("----idOne\(Float(ad.revenue))")
|
||||||
setPostload()
|
setPostload()
|
||||||
}
|
}
|
||||||
@ -232,5 +258,5 @@ extension AV_AddPlayerVC: MAAdDelegate
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,207 +0,0 @@
|
|||||||
//
|
|
||||||
// AV_EditPlayerVC.swift
|
|
||||||
// anniversary_Project
|
|
||||||
//
|
|
||||||
// Created by 忆海16 on 2024/7/21.
|
|
||||||
//
|
|
||||||
|
|
||||||
import UIKit
|
|
||||||
|
|
||||||
import AppLovinSDK
|
|
||||||
import Alamofire
|
|
||||||
import FirebaseRemoteConfig
|
|
||||||
|
|
||||||
|
|
||||||
class AV_EditPlayerVC: AV_RootVC {
|
|
||||||
|
|
||||||
var retryAttempt = 0.0
|
|
||||||
var interstitialAd: MAInterstitialAd!
|
|
||||||
var adCheckTimer: Timer?
|
|
||||||
var adCheckStartTime: Date?
|
|
||||||
var adLoadTime: Int = 0
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override func viewDidLoad() {
|
|
||||||
super.viewDidLoad()
|
|
||||||
// self.createInterstitialAd()
|
|
||||||
startAdCheck()
|
|
||||||
}
|
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
|
||||||
super.viewWillAppear(animated)
|
|
||||||
self.navigationController?.navigationBar.isHidden = true
|
|
||||||
|
|
||||||
}
|
|
||||||
///定时加载
|
|
||||||
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()
|
|
||||||
} else if elapsedTimeInMilliseconds >= 10000 { // 10000 毫秒 = 10 秒
|
|
||||||
adCheckTimer?.invalidate()
|
|
||||||
self.navigationController?.popViewController(animated: true)
|
|
||||||
|
|
||||||
} 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": "",
|
|
||||||
"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_EditPlayerVC: MAAdDelegate
|
|
||||||
{
|
|
||||||
func createInterstitialAd()
|
|
||||||
{
|
|
||||||
interstitialAd = MAInterstitialAd(adUnitIdentifier: "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 = "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()
|
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,108 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
|
|
||||||
<device id="retina6_12" orientation="portrait" appearance="light"/>
|
|
||||||
<dependencies>
|
|
||||||
<deployment identifier="iOS"/>
|
|
||||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22684"/>
|
|
||||||
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
|
|
||||||
<capability name="System colors in document resources" minToolsVersion="11.0"/>
|
|
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
|
||||||
</dependencies>
|
|
||||||
<objects>
|
|
||||||
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="AV_EditPlayerVC" customModule="anniversary_Project" customModuleProvider="target">
|
|
||||||
<connections>
|
|
||||||
<outlet property="view" destination="XO0-Br-1i9" id="wIi-qo-utp"/>
|
|
||||||
</connections>
|
|
||||||
</placeholder>
|
|
||||||
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
|
|
||||||
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="XO0-Br-1i9">
|
|
||||||
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
|
|
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
|
||||||
<subviews>
|
|
||||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Ex5-m0-Alj">
|
|
||||||
<rect key="frame" x="333" y="79" width="40" height="40"/>
|
|
||||||
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
|
|
||||||
<state key="normal" image="dismiss_edit"/>
|
|
||||||
</button>
|
|
||||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="15g-TA-clH">
|
|
||||||
<rect key="frame" x="22" y="139" width="349" height="484"/>
|
|
||||||
<subviews>
|
|
||||||
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="bgEdit" translatesAutoresizingMaskIntoConstraints="NO" id="haH-Gp-PBl">
|
|
||||||
<rect key="frame" x="2" y="2" width="345" height="300"/>
|
|
||||||
<constraints>
|
|
||||||
<constraint firstAttribute="height" constant="300" id="ngm-MC-D08"/>
|
|
||||||
</constraints>
|
|
||||||
</imageView>
|
|
||||||
<label opaque="NO" userInteractionEnabled="NO" alpha="0.5" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2024-5-10" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sz3-LM-D7V">
|
|
||||||
<rect key="frame" x="20" y="324" width="62" height="16"/>
|
|
||||||
<constraints>
|
|
||||||
<constraint firstAttribute="height" constant="16" id="Ima-s9-hSK"/>
|
|
||||||
</constraints>
|
|
||||||
<fontDescription key="fontDescription" type="system" pointSize="12"/>
|
|
||||||
<nil key="textColor"/>
|
|
||||||
<nil key="highlightedColor"/>
|
|
||||||
</label>
|
|
||||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Landing Page Agency Creative" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1FT-gE-2bz">
|
|
||||||
<rect key="frame" x="20" y="348" width="309" height="126"/>
|
|
||||||
<fontDescription key="fontDescription" type="system" pointSize="17"/>
|
|
||||||
<nil key="textColor"/>
|
|
||||||
<nil key="highlightedColor"/>
|
|
||||||
</label>
|
|
||||||
<switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="N6l-Rb-E0B">
|
|
||||||
<rect key="frame" x="280" y="316.66666666666669" width="51" height="31"/>
|
|
||||||
<color key="onTintColor" red="0.3596654534" green="0.56422770020000002" blue="0.96082669499999995" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
|
|
||||||
</switch>
|
|
||||||
</subviews>
|
|
||||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
|
||||||
<constraints>
|
|
||||||
<constraint firstAttribute="height" constant="484" id="BhM-d9-KF3"/>
|
|
||||||
<constraint firstItem="N6l-Rb-E0B" firstAttribute="centerY" secondItem="sz3-LM-D7V" secondAttribute="centerY" id="GqL-Gc-IAE"/>
|
|
||||||
<constraint firstItem="1FT-gE-2bz" firstAttribute="top" secondItem="sz3-LM-D7V" secondAttribute="bottom" constant="8" id="MH1-gf-2g5"/>
|
|
||||||
<constraint firstItem="haH-Gp-PBl" firstAttribute="leading" secondItem="15g-TA-clH" secondAttribute="leading" constant="2" id="Rmf-2J-7TT"/>
|
|
||||||
<constraint firstAttribute="trailing" secondItem="haH-Gp-PBl" secondAttribute="trailing" constant="2" id="Vms-La-Zwz"/>
|
|
||||||
<constraint firstItem="sz3-LM-D7V" firstAttribute="top" secondItem="haH-Gp-PBl" secondAttribute="bottom" constant="22" id="WRU-XL-uKq"/>
|
|
||||||
<constraint firstItem="sz3-LM-D7V" firstAttribute="leading" secondItem="15g-TA-clH" secondAttribute="leading" constant="20" id="ZAg-ke-MYz"/>
|
|
||||||
<constraint firstItem="haH-Gp-PBl" firstAttribute="top" secondItem="15g-TA-clH" secondAttribute="top" constant="2" id="Zat-aW-Fy1"/>
|
|
||||||
<constraint firstAttribute="bottom" secondItem="1FT-gE-2bz" secondAttribute="bottom" constant="10" id="eWB-bW-NbV"/>
|
|
||||||
<constraint firstItem="1FT-gE-2bz" firstAttribute="leading" secondItem="15g-TA-clH" secondAttribute="leading" constant="20" id="fq7-kl-e8U"/>
|
|
||||||
<constraint firstAttribute="trailing" secondItem="1FT-gE-2bz" secondAttribute="trailing" constant="20" id="g2I-3u-mEQ"/>
|
|
||||||
<constraint firstAttribute="trailing" secondItem="N6l-Rb-E0B" secondAttribute="trailing" constant="20" id="xEH-9c-FDl"/>
|
|
||||||
</constraints>
|
|
||||||
</view>
|
|
||||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JS0-6J-Q7h">
|
|
||||||
<rect key="frame" x="64.666666666666671" y="633" width="104.00000000000001" height="104"/>
|
|
||||||
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
|
|
||||||
<state key="normal" image="edit_add"/>
|
|
||||||
</button>
|
|
||||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="BN5-XV-2gK">
|
|
||||||
<rect key="frame" x="224.66666666666663" y="633" width="104" height="104"/>
|
|
||||||
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
|
|
||||||
<state key="normal" image="edit_delete"/>
|
|
||||||
</button>
|
|
||||||
</subviews>
|
|
||||||
<viewLayoutGuide key="safeArea" id="xcB-bl-6Hq"/>
|
|
||||||
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
|
|
||||||
<constraints>
|
|
||||||
<constraint firstItem="xcB-bl-6Hq" firstAttribute="trailing" secondItem="Ex5-m0-Alj" secondAttribute="trailing" constant="20" id="04z-Hs-IYz"/>
|
|
||||||
<constraint firstItem="JS0-6J-Q7h" firstAttribute="top" secondItem="15g-TA-clH" secondAttribute="bottom" constant="10" id="76h-Bh-iHy"/>
|
|
||||||
<constraint firstItem="JS0-6J-Q7h" firstAttribute="centerX" secondItem="15g-TA-clH" secondAttribute="centerX" constant="-80" id="81Z-GG-51S"/>
|
|
||||||
<constraint firstItem="BN5-XV-2gK" firstAttribute="top" secondItem="15g-TA-clH" secondAttribute="bottom" constant="10" id="BcW-Qc-AyF"/>
|
|
||||||
<constraint firstItem="Ex5-m0-Alj" firstAttribute="top" secondItem="xcB-bl-6Hq" secondAttribute="top" constant="20" id="Q4O-pw-aot"/>
|
|
||||||
<constraint firstItem="15g-TA-clH" firstAttribute="leading" secondItem="xcB-bl-6Hq" secondAttribute="leading" constant="22" id="Vv5-Q7-jys"/>
|
|
||||||
<constraint firstItem="xcB-bl-6Hq" firstAttribute="trailing" secondItem="15g-TA-clH" secondAttribute="trailing" constant="22" id="b5h-Zz-xMr"/>
|
|
||||||
<constraint firstItem="BN5-XV-2gK" firstAttribute="centerX" secondItem="XO0-Br-1i9" secondAttribute="centerX" constant="80" id="ekE-Rn-GHv"/>
|
|
||||||
<constraint firstItem="15g-TA-clH" firstAttribute="top" secondItem="Ex5-m0-Alj" secondAttribute="bottom" constant="20" id="m5s-u5-cF9"/>
|
|
||||||
</constraints>
|
|
||||||
<point key="canvasLocation" x="130.43478260869566" y="-11.383928571428571"/>
|
|
||||||
</view>
|
|
||||||
</objects>
|
|
||||||
<resources>
|
|
||||||
<image name="bgEdit" width="331" height="294"/>
|
|
||||||
<image name="dismiss_edit" width="40" height="40"/>
|
|
||||||
<image name="edit_add" width="104" height="104"/>
|
|
||||||
<image name="edit_delete" width="104" height="104"/>
|
|
||||||
<systemColor name="systemBackgroundColor">
|
|
||||||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
|
||||||
</systemColor>
|
|
||||||
</resources>
|
|
||||||
</document>
|
|
||||||
@ -14,7 +14,7 @@ import FirebaseRemoteConfig
|
|||||||
|
|
||||||
|
|
||||||
class AV_MinePlayerVC: AV_RootVC {
|
class AV_MinePlayerVC: AV_RootVC {
|
||||||
|
|
||||||
|
|
||||||
var retryAttempt = 0.0
|
var retryAttempt = 0.0
|
||||||
var interstitialAd: MAInterstitialAd!
|
var interstitialAd: MAInterstitialAd!
|
||||||
@ -22,11 +22,11 @@ class AV_MinePlayerVC: AV_RootVC {
|
|||||||
var adCheckStartTime: Date?
|
var adCheckStartTime: Date?
|
||||||
var adLoadTime: Int = 0
|
var adLoadTime: Int = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
// self.createInterstitialAd()
|
// self.createInterstitialAd()
|
||||||
startAdCheck()
|
startAdCheck()
|
||||||
}
|
}
|
||||||
override func viewWillAppear(_ animated: Bool) {
|
override func viewWillAppear(_ animated: Bool) {
|
||||||
@ -36,7 +36,7 @@ class AV_MinePlayerVC: AV_RootVC {
|
|||||||
}
|
}
|
||||||
///定时加载
|
///定时加载
|
||||||
func startAdCheck() {
|
func startAdCheck() {
|
||||||
// createInterstitialAd()
|
// createInterstitialAd()
|
||||||
adCheckStartTime = Date()
|
adCheckStartTime = Date()
|
||||||
adCheckTimer = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(checkAdStatus), userInfo: nil, repeats: true)
|
adCheckTimer = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(checkAdStatus), userInfo: nil, repeats: true)
|
||||||
}
|
}
|
||||||
@ -49,6 +49,7 @@ class AV_MinePlayerVC: AV_RootVC {
|
|||||||
interstitialAd.show()
|
interstitialAd.show()
|
||||||
adLoadTime = elapsedTimeInMilliseconds // 记录加载
|
adLoadTime = elapsedTimeInMilliseconds // 记录加载
|
||||||
adCheckTimer?.invalidate()
|
adCheckTimer?.invalidate()
|
||||||
|
setShow()
|
||||||
} else if elapsedTimeInMilliseconds >= 10000 { // 10000 毫秒 = 10 秒
|
} else if elapsedTimeInMilliseconds >= 10000 { // 10000 毫秒 = 10 秒
|
||||||
adCheckTimer?.invalidate()
|
adCheckTimer?.invalidate()
|
||||||
self.navigationController?.popViewController(animated: true)
|
self.navigationController?.popViewController(animated: true)
|
||||||
@ -57,7 +58,7 @@ class AV_MinePlayerVC: AV_RootVC {
|
|||||||
print("广告未准备好,继续检查...")
|
print("广告未准备好,继续检查...")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setPostload(){
|
func setPostload(){
|
||||||
let url = "http://111.9.47.226:38080/top_selection/save_ad_load_log"
|
let url = "http://111.9.47.226:38080/top_selection/save_ad_load_log"
|
||||||
let parameters:[String : Any] = [
|
let parameters:[String : Any] = [
|
||||||
@ -138,6 +139,25 @@ class AV_MinePlayerVC: AV_RootVC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func setShow() {
|
||||||
|
let idfa = StartManager.shared.idfaid
|
||||||
|
let adId = StartManager.shared.idTwoAD
|
||||||
|
let ecpm = StartManager.shared.idTwoprice
|
||||||
|
|
||||||
|
AdLoader.shared.showAd(idfa: idfa, adId: adId, ecpm: ecpm) { result in
|
||||||
|
switch result {
|
||||||
|
case .success(let closeTime): break
|
||||||
|
// let seconds = millisecondsToSeconds(milliseconds: closeTime)
|
||||||
|
// DispatchQueue.main.asyncAfter(deadline: .now() + seconds) {
|
||||||
|
// closeADWindow()
|
||||||
|
// }
|
||||||
|
case .failure(let error):
|
||||||
|
print("Error:--- \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
extension AV_MinePlayerVC: MAAdDelegate
|
extension AV_MinePlayerVC: MAAdDelegate
|
||||||
{
|
{
|
||||||
@ -167,7 +187,7 @@ extension AV_MinePlayerVC: MAAdDelegate
|
|||||||
StartManager.shared.ecpm = Float(ad.revenue)
|
StartManager.shared.ecpm = Float(ad.revenue)
|
||||||
StartManager.shared.dsp = ad.dspName
|
StartManager.shared.dsp = ad.dspName
|
||||||
StartManager.shared.network = ad.networkName
|
StartManager.shared.network = ad.networkName
|
||||||
StartManager.shared.idTwo = Float(ad.revenue)
|
StartManager.shared.idTwoprice = Float(ad.revenue)
|
||||||
print("----idTwo\(Float(ad.revenue))")
|
print("----idTwo\(Float(ad.revenue))")
|
||||||
setPostload()
|
setPostload()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,6 +61,7 @@ class AV_RootPlayerVC: AV_RootVC {
|
|||||||
vc.interstitialAd = self.interstitialAd1
|
vc.interstitialAd = self.interstitialAd1
|
||||||
// vc.createInterstitialAd()
|
// vc.createInterstitialAd()
|
||||||
self.navigationController?.pushViewController(vc, animated: true)
|
self.navigationController?.pushViewController(vc, animated: true)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8fccdfa964b52e26
|
// 8fccdfa964b52e26
|
||||||
@ -70,10 +71,12 @@ class AV_RootPlayerVC: AV_RootVC {
|
|||||||
// vc.createInterstitialAd()
|
// vc.createInterstitialAd()
|
||||||
vc.interstitialAd = self.interstitialAd2
|
vc.interstitialAd = self.interstitialAd2
|
||||||
self.navigationController?.pushViewController(vc, animated: true)
|
self.navigationController?.pushViewController(vc, animated: true)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7baed02646413e44
|
// 7baed02646413e44
|
||||||
@IBAction func three(_ sender: Any) {
|
@IBAction func three(_ sender: Any) {
|
||||||
|
|
||||||
let vc = AV_WaterKeyBordPlayerVC()
|
let vc = AV_WaterKeyBordPlayerVC()
|
||||||
vc.interstitialAd = self.interstitialAd3
|
vc.interstitialAd = self.interstitialAd3
|
||||||
// vc.createInterstitialAd()
|
// vc.createInterstitialAd()
|
||||||
@ -82,93 +85,204 @@ class AV_RootPlayerVC: AV_RootVC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func setLoaded1(){
|
// func setLoaded1(){
|
||||||
let parameters:[String : Any] = [
|
// let parameters:[String : Any] = [
|
||||||
"appid": "com.countdown.day.daycount",
|
// "appid": "com.countdown.day.daycount",
|
||||||
"idfa":StartManager.shared.idfaid ?? "",
|
// "idfa":StartManager.shared.idfaid ?? "",
|
||||||
"ads": [
|
// "ads": [
|
||||||
[
|
// [
|
||||||
"id": StartManager.shared.idOneAD,
|
// "id": StartManager.shared.idOneAD,
|
||||||
"btn_position": [
|
// "btn_position": [
|
||||||
"x": StartManager.shared.idOnex,
|
// "x": StartManager.shared.idOnex,
|
||||||
"y": StartManager.shared.idOney
|
// "y": StartManager.shared.idOney
|
||||||
],
|
// ],
|
||||||
"ecpm": StartManager.shared.idOne ?? ""
|
// "ecpm": StartManager.shared.idOne ?? ""
|
||||||
]
|
// ]
|
||||||
]
|
// ]
|
||||||
]
|
// ]
|
||||||
NetworkManager.shared.postRequest(url: StartManager.shared.loadurl, parameters: parameters, headers: StartManager.shared.headers) { result in
|
// NetworkManager.shared.postRequest(url: StartManager.shared.loadurl, parameters: parameters, headers: StartManager.shared.headers) { result in
|
||||||
switch result {
|
// switch result {
|
||||||
case .success(let data):
|
// case .success(let data):
|
||||||
print("Response:--- \(data)")
|
// print("Response:--- \(data)")
|
||||||
case .failure(let error):
|
// if let status = data["status"] as? String, status == "Success" {
|
||||||
print("Error:--- \(error)")
|
// if let needLoad = data["needload"] as? Int {
|
||||||
}
|
// if needLoad > 0 {
|
||||||
}
|
// print("Need to load \(needLoad) more ads.")
|
||||||
|
// // 执行加载更多广告的逻辑
|
||||||
}
|
// } else {
|
||||||
func setLoaded2(){
|
// print("No need to load more ads.")
|
||||||
let parameters:[String : Any] = [
|
// // 不需要加载更多广告的逻辑
|
||||||
"appid": "com.countdown.day.daycount",
|
// }
|
||||||
"idfa":StartManager.shared.idfaid ?? "",
|
// }
|
||||||
"ads": [
|
// }
|
||||||
[
|
// case .failure(let error):
|
||||||
"id": StartManager.shared.idTwoAD,
|
// print("Error:--- \(error)")
|
||||||
"btn_position": [
|
// }
|
||||||
"x": StartManager.shared.idTwox,
|
// }
|
||||||
"y": StartManager.shared.idTwoy
|
//
|
||||||
],
|
// }
|
||||||
"ecpm": StartManager.shared.idTwo ?? ""
|
//
|
||||||
]
|
// func setLoaded2(){
|
||||||
]
|
// let parameters:[String : Any] = [
|
||||||
]
|
// "appid": "com.countdown.day.daycount",
|
||||||
NetworkManager.shared.postRequest(url: StartManager.shared.loadurl, parameters: parameters, headers: StartManager.shared.headers) { result in
|
// "idfa":StartManager.shared.idfaid ?? "",
|
||||||
switch result {
|
// "ads": [
|
||||||
case .success(let data):
|
// [
|
||||||
print("Response:--- \(data)")
|
// "id": StartManager.shared.idTwoAD,
|
||||||
case .failure(let error):
|
// "btn_position": [
|
||||||
print("Error:--- \(error)")
|
// "x": StartManager.shared.idTwox,
|
||||||
}
|
// "y": StartManager.shared.idTwoy
|
||||||
}
|
// ],
|
||||||
|
// "ecpm": StartManager.shared.idTwo ?? ""
|
||||||
}
|
// ]
|
||||||
|
// ]
|
||||||
|
// ]
|
||||||
|
// NetworkManager.shared.postRequest(url: StartManager.shared.loadurl, parameters: parameters, headers: StartManager.shared.headers) { result in
|
||||||
|
// switch result {
|
||||||
|
// case .success(let data):
|
||||||
|
// print("Response:--- \(data)")
|
||||||
|
// if let status = data["status"] as? String, status == "Success" {
|
||||||
|
// if let needLoad = data["needload"] as? Int {
|
||||||
|
// if needLoad > 0 {
|
||||||
|
// print("Need to load \(needLoad) more ads.")
|
||||||
|
// // 执行加载更多广告的逻辑
|
||||||
|
// } else {
|
||||||
|
// print("No need to load more ads.")
|
||||||
|
// // 不需要加载更多广告的逻辑
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// case .failure(let error):
|
||||||
|
// print("Error:--- \(error)")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// func setLoaded3(){
|
||||||
|
// let parameters:[String : Any] = [
|
||||||
|
// "appid": "com.countdown.day.daycount",
|
||||||
|
// "idfa":StartManager.shared.idfaid ?? "",
|
||||||
|
// "ads": [
|
||||||
|
// [
|
||||||
|
// "id": StartManager.shared.idThreeAD,
|
||||||
|
// "btn_position": [
|
||||||
|
// "x": StartManager.shared.idThreex,
|
||||||
|
// "y": StartManager.shared.idThreey
|
||||||
|
// ],
|
||||||
|
// "ecpm": StartManager.shared.idThree ?? ""
|
||||||
|
// ]
|
||||||
|
// ]
|
||||||
|
// ]
|
||||||
|
// NetworkManager.shared.postRequest(url: StartManager.shared.loadurl, parameters: parameters, headers:StartManager.shared.headers) { result in
|
||||||
|
// switch result {
|
||||||
|
// case .success(let data):
|
||||||
|
// print("Response:--- \(data)")
|
||||||
|
// if let status = data["status"] as? String, status == "Success" {
|
||||||
|
// if let needLoad = data["needload"] as? Int {
|
||||||
|
// if needLoad > 0 {
|
||||||
|
// print("Need to load \(needLoad) more ads.")
|
||||||
|
// // 执行加载更多广告的逻辑
|
||||||
|
// } else {
|
||||||
|
// print("No need to load more ads.")
|
||||||
|
// // 不需要加载更多广告的逻辑
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// case .failure(let error):
|
||||||
|
// print("Error:--- \(error)")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
func setLoaded1() {
|
||||||
|
let idfa = StartManager.shared.idfaid
|
||||||
|
let adId = StartManager.shared.idOneAD
|
||||||
|
let btnPositionX = StartManager.shared.idOnex
|
||||||
|
let btnPositionY = StartManager.shared.idOney
|
||||||
|
let ecpm = StartManager.shared.idOneprice
|
||||||
|
|
||||||
func setLoaded3(){
|
AdLoader.shared.loadAds( idfa: idfa, adId: adId, btnPositionX: btnPositionX, btnPositionY: btnPositionY, ecpm: ecpm) { result in
|
||||||
let parameters:[String : Any] = [
|
switch result {
|
||||||
"appid": "com.countdown.day.daycount",
|
case .success(let needLoad):
|
||||||
"idfa":StartManager.shared.idfaid ?? "",
|
if needLoad > 0 {
|
||||||
"ads": [
|
print("Need to load \(needLoad) more ads.")
|
||||||
[
|
// 执行加载更多广告的逻辑
|
||||||
"id": StartManager.shared.idThreeAD,
|
} else {
|
||||||
"btn_position": [
|
print("No need to load more ads.")
|
||||||
"x": StartManager.shared.idThreex,
|
// 不需要加载更多广告的逻辑
|
||||||
"y": StartManager.shared.idThreey
|
}
|
||||||
],
|
case .failure(let error):
|
||||||
"ecpm": StartManager.shared.idThree ?? ""
|
print("Error:--- \(error)")
|
||||||
]
|
}
|
||||||
]
|
}
|
||||||
]
|
|
||||||
NetworkManager.shared.postRequest(url: StartManager.shared.loadurl, parameters: parameters, headers:StartManager.shared.headers) { result in
|
|
||||||
switch result {
|
|
||||||
case .success(let data):
|
|
||||||
print("Response:--- \(data)")
|
|
||||||
if let status = data["status"] as? String, status == "Success" {
|
|
||||||
if let needLoad = data["needload"] as? Int {
|
|
||||||
if needLoad > 0 {
|
|
||||||
print("Need to load \(needLoad) more ads.")
|
|
||||||
// 执行加载更多广告的逻辑
|
|
||||||
} else {
|
|
||||||
print("No need to load more ads.")
|
|
||||||
// 不需要加载更多广告的逻辑
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case .failure(let error):
|
|
||||||
print("Error:--- \(error)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setLoaded2() {
|
||||||
|
let idfa = StartManager.shared.idfaid
|
||||||
|
let adId = StartManager.shared.idTwoAD
|
||||||
|
let btnPositionX = StartManager.shared.idTwox
|
||||||
|
let btnPositionY = StartManager.shared.idTwoy
|
||||||
|
let ecpm = StartManager.shared.idTwoprice
|
||||||
|
|
||||||
|
AdLoader.shared.loadAds( idfa: idfa, adId: adId, btnPositionX: btnPositionX, btnPositionY: btnPositionY, ecpm: ecpm) { result in
|
||||||
|
switch result {
|
||||||
|
case .success(let needLoad):
|
||||||
|
if needLoad > 0 {
|
||||||
|
print("Need to load \(needLoad) more ads.")
|
||||||
|
// 执行加载更多广告的逻辑
|
||||||
|
} else {
|
||||||
|
print("No need to load more ads.")
|
||||||
|
// 不需要加载更多广告的逻辑
|
||||||
|
}
|
||||||
|
case .failure(let error):
|
||||||
|
print("Error:--- \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setLoaded3() {
|
||||||
|
let idfa = StartManager.shared.idfaid
|
||||||
|
let adId = StartManager.shared.idThreeAD
|
||||||
|
let btnPositionX = StartManager.shared.idThreex
|
||||||
|
let btnPositionY = StartManager.shared.idThreey
|
||||||
|
let ecpm = StartManager.shared.idThreeprice
|
||||||
|
|
||||||
|
AdLoader.shared.loadAds( idfa: idfa, adId: adId, btnPositionX: btnPositionX, btnPositionY: btnPositionY, ecpm: ecpm) { result in
|
||||||
|
switch result {
|
||||||
|
case .success(let needLoad):
|
||||||
|
if needLoad > 0 {
|
||||||
|
print("Need to load \(needLoad) more ads.")
|
||||||
|
// 执行加载更多广告的逻辑
|
||||||
|
} else {
|
||||||
|
print("No need to load more ads.")
|
||||||
|
// 不需要加载更多广告的逻辑
|
||||||
|
}
|
||||||
|
case .failure(let error):
|
||||||
|
print("Error:--- \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// func setclosed(adid:String){
|
||||||
|
// let parameters:[String : Any] = [
|
||||||
|
// "appid": "com.countdown.day.daycount",
|
||||||
|
// "idfa":StartManager.shared.idfaid ?? "",
|
||||||
|
// "id":adid,
|
||||||
|
//
|
||||||
|
// ]
|
||||||
|
// NetworkManager.shared.postRequest(url: StartManager.shared.closedUrl, parameters: parameters, headers: StartManager.shared.headers) { result in
|
||||||
|
// switch result {
|
||||||
|
// case .success(let data):
|
||||||
|
// print("Response:--- \(data)")
|
||||||
|
// case .failure(let error):
|
||||||
|
// print("Error:--- \(error)")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,22 +340,19 @@ extension AV_RootPlayerVC: MAAdDelegate
|
|||||||
// setPostload()
|
// setPostload()
|
||||||
|
|
||||||
if StartManager.shared.IDADType == 1{
|
if StartManager.shared.IDADType == 1{
|
||||||
StartManager.shared.idOne = Float(ad.revenue)
|
StartManager.shared.idOneprice = Float(ad.revenue)
|
||||||
self.setLoaded1()
|
self.setLoaded1()
|
||||||
StartManager.shared.IDADType = 2
|
StartManager.shared.IDADType = 2
|
||||||
createInterstitialAd()
|
createInterstitialAd()
|
||||||
}else if StartManager.shared.IDADType == 2{
|
}else if StartManager.shared.IDADType == 2{
|
||||||
StartManager.shared.idTwo = Float(ad.revenue)
|
StartManager.shared.idTwoprice = Float(ad.revenue)
|
||||||
self.setLoaded2()
|
self.setLoaded2()
|
||||||
StartManager.shared.IDADType = 3
|
StartManager.shared.IDADType = 3
|
||||||
createInterstitialAd()
|
createInterstitialAd()
|
||||||
}else if StartManager.shared.IDADType == 3{
|
}else if StartManager.shared.IDADType == 3{
|
||||||
StartManager.shared.idThree = Float(ad.revenue)
|
StartManager.shared.idThreeprice = Float(ad.revenue)
|
||||||
self.setLoaded3()
|
self.setLoaded3()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError)
|
func didFailToLoadAd(forAdUnitIdentifier adUnitIdentifier: String, withError error: MAError)
|
||||||
@ -275,6 +386,16 @@ extension AV_RootPlayerVC: MAAdDelegate
|
|||||||
// 插页式广告已隐藏。预加载下一个广告
|
// 插页式广告已隐藏。预加载下一个广告
|
||||||
// interstitialAd1.load()
|
// interstitialAd1.load()
|
||||||
// self.navigationController?.popViewController(animated: true)
|
// self.navigationController?.popViewController(animated: true)
|
||||||
|
// setclosed(adid: ad.adUnitIdentifier)
|
||||||
|
AdLoader.shared.closeAd(idfa: StartManager.shared.idfaid, adId: ad.adUnitIdentifier) { result in
|
||||||
|
switch result {
|
||||||
|
case .success(let data):
|
||||||
|
print("Response:--- \(data)")
|
||||||
|
case .failure(let error):
|
||||||
|
print("Error:--- \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
navigationController?.popViewController(animated: true)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,10 +38,10 @@ class AV_WaterKeyBordPlayerVC: AV_RootVC {
|
|||||||
var adLoadTime: Int = 0
|
var adLoadTime: Int = 0
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
setcollectionV()
|
setcollectionV()
|
||||||
rulerV = MLSliderRulerView(frame:cupuView.bounds)
|
rulerV = MLSliderRulerView(frame:cupuView.bounds)
|
||||||
|
|
||||||
self.cupuView.addSubview(rulerV)
|
self.cupuView.addSubview(rulerV)
|
||||||
startAdCheck()
|
startAdCheck()
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ class AV_WaterKeyBordPlayerVC: AV_RootVC {
|
|||||||
}
|
}
|
||||||
///定时加载
|
///定时加载
|
||||||
func startAdCheck() {
|
func startAdCheck() {
|
||||||
// createInterstitialAd()
|
// createInterstitialAd()
|
||||||
adCheckStartTime = Date()
|
adCheckStartTime = Date()
|
||||||
adCheckTimer = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(checkAdStatus), userInfo: nil, repeats: true)
|
adCheckTimer = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(checkAdStatus), userInfo: nil, repeats: true)
|
||||||
}
|
}
|
||||||
@ -66,6 +66,7 @@ class AV_WaterKeyBordPlayerVC: AV_RootVC {
|
|||||||
interstitialAd.show()
|
interstitialAd.show()
|
||||||
adLoadTime = elapsedTimeInMilliseconds // 记录加载
|
adLoadTime = elapsedTimeInMilliseconds // 记录加载
|
||||||
adCheckTimer?.invalidate()
|
adCheckTimer?.invalidate()
|
||||||
|
setShow()
|
||||||
} else if elapsedTimeInMilliseconds >= 10000 { // 10000 毫秒 = 10 秒
|
} else if elapsedTimeInMilliseconds >= 10000 { // 10000 毫秒 = 10 秒
|
||||||
adCheckTimer?.invalidate()
|
adCheckTimer?.invalidate()
|
||||||
self.navigationController?.popViewController(animated: true)
|
self.navigationController?.popViewController(animated: true)
|
||||||
@ -74,7 +75,7 @@ class AV_WaterKeyBordPlayerVC: AV_RootVC {
|
|||||||
print("广告未准备好,继续检查...")
|
print("广告未准备好,继续检查...")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setPostload(){
|
func setPostload(){
|
||||||
let url = "http://111.9.47.226:38080/top_selection/save_ad_load_log"
|
let url = "http://111.9.47.226:38080/top_selection/save_ad_load_log"
|
||||||
let parameters:[String : Any] = [
|
let parameters:[String : Any] = [
|
||||||
@ -155,7 +156,7 @@ class AV_WaterKeyBordPlayerVC: AV_RootVC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func setcollectionV(){
|
func setcollectionV(){
|
||||||
let layout = UICollectionViewFlowLayout()
|
let layout = UICollectionViewFlowLayout()
|
||||||
layout.scrollDirection = .horizontal
|
layout.scrollDirection = .horizontal
|
||||||
@ -164,6 +165,51 @@ class AV_WaterKeyBordPlayerVC: AV_RootVC {
|
|||||||
collectionView.collectionViewLayout = layout
|
collectionView.collectionViewLayout = layout
|
||||||
collectionView.register(UINib(nibName: "AV_AddWaterVCCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "AV_AddWaterVCCollectionViewCell")
|
collectionView.register(UINib(nibName: "AV_AddWaterVCCollectionViewCell", bundle: nil), forCellWithReuseIdentifier: "AV_AddWaterVCCollectionViewCell")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// func setshow(){
|
||||||
|
// let parameters:[String : Any] = [
|
||||||
|
// "appid": "com.countdown.day.daycount",
|
||||||
|
// "idfa":StartManager.shared.idfaid ?? "",
|
||||||
|
// "id":StartManager.shared.idOneAD,
|
||||||
|
// "ecpm":StartManager.shared.idOneprice ?? "",
|
||||||
|
//
|
||||||
|
// ]
|
||||||
|
// NetworkManager.shared.postRequest(url: StartManager.shared.showurl, parameters: parameters, headers: StartManager.shared.headers) { result in
|
||||||
|
// switch result {
|
||||||
|
// case .success(let data):
|
||||||
|
// print("Response:--- \(data)")
|
||||||
|
// if let status = data["status"] as? String, status == "Success" {
|
||||||
|
// if let needLoad = data["close"] as? Int {
|
||||||
|
// let seconds = millisecondsToSeconds(milliseconds: needLoad)
|
||||||
|
//
|
||||||
|
// DispatchQueue.main.asyncAfter(wallDeadline: .now() + seconds) {
|
||||||
|
// closeADWindow()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// case .failure(let error):
|
||||||
|
// print("Error:--- \(error)")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
func setShow() {
|
||||||
|
let idfa = StartManager.shared.idfaid
|
||||||
|
let adId = StartManager.shared.idThreeAD
|
||||||
|
let ecpm = StartManager.shared.idThreeprice
|
||||||
|
|
||||||
|
AdLoader.shared.showAd(idfa: idfa, adId: adId, ecpm: ecpm) { result in
|
||||||
|
switch result {
|
||||||
|
case .success(let closeTime): break
|
||||||
|
// let seconds = millisecondsToSeconds(milliseconds: closeTime)
|
||||||
|
// DispatchQueue.main.asyncAzfter(deadline: .now() + seconds) {
|
||||||
|
// closeADWindow()
|
||||||
|
// }
|
||||||
|
case .failure(let error):
|
||||||
|
print("Error:--- \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
extension AV_WaterKeyBordPlayerVC: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource,UICollectionViewDelegate{
|
extension AV_WaterKeyBordPlayerVC: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource,UICollectionViewDelegate{
|
||||||
|
|
||||||
@ -227,7 +273,7 @@ extension AV_WaterKeyBordPlayerVC: MAAdDelegate
|
|||||||
StartManager.shared.dsp = ad.dspName
|
StartManager.shared.dsp = ad.dspName
|
||||||
StartManager.shared.network = ad.networkName
|
StartManager.shared.network = ad.networkName
|
||||||
|
|
||||||
StartManager.shared.idThree = Float(ad.revenue)
|
StartManager.shared.idThreeprice = Float(ad.revenue)
|
||||||
|
|
||||||
print("----idThree\(Float(ad.revenue))")
|
print("----idThree\(Float(ad.revenue))")
|
||||||
|
|
||||||
|
|||||||
144
anniversary_Project/Tool/ADopen/adNetWork.swift
Normal file
144
anniversary_Project/Tool/ADopen/adNetWork.swift
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
//
|
||||||
|
// adopen.swift
|
||||||
|
// anniversary_Project
|
||||||
|
//
|
||||||
|
// Created by 忆海16 on 2024/7/23.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import UIKit
|
||||||
|
import Alamofire
|
||||||
|
|
||||||
|
class NetworkManager {
|
||||||
|
static let shared = NetworkManager()
|
||||||
|
|
||||||
|
private init() {}
|
||||||
|
|
||||||
|
func postRequest(url: String, parameters: [String: Any], headers: HTTPHeaders, completion: @escaping (Result<[String: Any], Error>) -> Void) {
|
||||||
|
AF.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: headers).responseJSON { response in
|
||||||
|
switch response.result {
|
||||||
|
case .success(let value):
|
||||||
|
if let json = value as? [String: Any] {
|
||||||
|
completion(.success(json))
|
||||||
|
} else {
|
||||||
|
let error = NSError(domain: "", code: -1, userInfo: [NSLocalizedDescriptionKey: "Invalid response format"])
|
||||||
|
completion(.failure(error))
|
||||||
|
}
|
||||||
|
case .failure(let afError):
|
||||||
|
completion(.failure(afError))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class AdLoader {
|
||||||
|
static let shared = AdLoader()
|
||||||
|
|
||||||
|
private init() {}
|
||||||
|
|
||||||
|
/// Load
|
||||||
|
func loadAds( idfa: String?, adId: String, btnPositionX: CGFloat, btnPositionY: CGFloat, ecpm: Float?, completion: @escaping (Result<Int, Error>) -> Void) {
|
||||||
|
let parameters: [String: Any] = [
|
||||||
|
"appid": "com.countdown.day.daycount",
|
||||||
|
"idfa": idfa ?? "",
|
||||||
|
"ads": [
|
||||||
|
[
|
||||||
|
"id": adId,
|
||||||
|
"btn_position": [
|
||||||
|
"x": btnPositionX,
|
||||||
|
"y": btnPositionY
|
||||||
|
],
|
||||||
|
"ecpm": ecpm ?? ""
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
NetworkManager.shared.postRequest(url: StartManager.shared.loadurl, parameters: parameters, headers: StartManager.shared.headers) { result in
|
||||||
|
switch result {
|
||||||
|
case .success(let data):
|
||||||
|
if let status = data["status"] as? String, status == "Success" {
|
||||||
|
if let needLoad = data["needload"] as? Int {
|
||||||
|
completion(.success(needLoad))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let error = NSError(domain: "", code: -1, userInfo: [NSLocalizedDescriptionKey: "Invalid response format"])
|
||||||
|
completion(.failure(error))
|
||||||
|
case .failure(let error):
|
||||||
|
completion(.failure(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// closd
|
||||||
|
func closeAd( idfa: String?, adId: String, completion: @escaping (Result<[String: Any], Error>) -> Void) {
|
||||||
|
let parameters: [String: Any] = [
|
||||||
|
"appid": "com.countdown.day.daycount",
|
||||||
|
"idfa": idfa ?? "",
|
||||||
|
"id": adId
|
||||||
|
]
|
||||||
|
|
||||||
|
NetworkManager.shared.postRequest(url: StartManager.shared.closedUrl, parameters: parameters, headers: StartManager.shared.headers) { result in
|
||||||
|
completion(result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// show
|
||||||
|
func showAd(idfa: String?, adId: String, ecpm: Float?, completion: @escaping (Result<Int, Error>) -> Void) {
|
||||||
|
let parameters: [String: Any] = [
|
||||||
|
"appid": "com.countdown.day.daycount",
|
||||||
|
"idfa": idfa ?? "",
|
||||||
|
"id": adId,
|
||||||
|
"ecpm": ecpm ?? ""
|
||||||
|
]
|
||||||
|
|
||||||
|
NetworkManager.shared.postRequest(url:StartManager.shared.showurl , parameters: parameters, headers: StartManager.shared.headers) { result in
|
||||||
|
switch result {
|
||||||
|
case .success(let data):
|
||||||
|
print("Response:--- \(data)")
|
||||||
|
if let status = data["status"] as? String, status == "Success" {
|
||||||
|
if let closeTime = data["close"] as? Int {
|
||||||
|
completion(.success(closeTime))
|
||||||
|
let seconds = millisecondsToSeconds(milliseconds: closeTime)
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + seconds) {
|
||||||
|
closeADWindow()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let error = NSError(domain: "", code: -1, userInfo: [NSLocalizedDescriptionKey: "Invalid response format"])
|
||||||
|
completion(.failure(error))
|
||||||
|
case .failure(let error):
|
||||||
|
completion(.failure(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///毫秒转秒
|
||||||
|
func millisecondsToSeconds(milliseconds: Int) -> Double {
|
||||||
|
|
||||||
|
return Double(milliseconds) / 1000.0
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
///Widows
|
||||||
|
func closeADWindow() {
|
||||||
|
if let keyWindow = UIApplication.shared.keyWindow {
|
||||||
|
for subview in keyWindow.subviews {
|
||||||
|
if let vc = subview.subviews.first?.next as? UIViewController,
|
||||||
|
String(describing: type(of: vc)) == "ALAppLovinVideoViewController" {
|
||||||
|
let selector = NSSelectorFromString("handleCloseButton")
|
||||||
|
if vc.responds(to: selector) {
|
||||||
|
vc.perform(selector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -9,52 +9,3 @@ import Foundation
|
|||||||
|
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
class NetworkManager {
|
|
||||||
static let shared = NetworkManager()
|
|
||||||
|
|
||||||
private init() {}
|
|
||||||
|
|
||||||
/// 封装的POST请求
|
|
||||||
/// - Parameters:
|
|
||||||
/// - url: 请求的URL字符串
|
|
||||||
/// - parameters: 请求参数
|
|
||||||
/// - headers: 请求头
|
|
||||||
/// - completion: 请求完成的回调
|
|
||||||
// func postRequest(url: String, parameters: [String: Any]?, headers: HTTPHeaders?, completion: @escaping (Result<Any, AFError>) -> Void) {
|
|
||||||
// AF.request(url,
|
|
||||||
// method: .post,
|
|
||||||
// parameters: parameters,
|
|
||||||
// encoding: JSONEncoding.default,
|
|
||||||
// headers: headers)
|
|
||||||
// .validate()
|
|
||||||
// .responseJSON { response in
|
|
||||||
// switch response.result {
|
|
||||||
// case .success(let data):
|
|
||||||
// completion(.success(data))
|
|
||||||
// case .failure(let error):
|
|
||||||
// completion(.failure(error))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
func postRequest(url: String, parameters: [String: Any]?, headers: HTTPHeaders?, completion: @escaping (Result<[String: Any], AFError>) -> Void) {
|
|
||||||
AF.request(url,
|
|
||||||
method: .post,
|
|
||||||
parameters: parameters,
|
|
||||||
encoding: JSONEncoding.default,
|
|
||||||
headers: headers)
|
|
||||||
.validate()
|
|
||||||
.responseJSON { response in
|
|
||||||
switch response.result {
|
|
||||||
case .success(let data):
|
|
||||||
if let jsonData = data as? [String: Any] {
|
|
||||||
completion(.success(jsonData))
|
|
||||||
} else {
|
|
||||||
completion(.failure(AFError.responseValidationFailed(reason: .dataFileNil)))
|
|
||||||
}
|
|
||||||
case .failure(let error):
|
|
||||||
completion(.failure(error))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@ -51,19 +51,19 @@ class StartManager:NSObject{
|
|||||||
|
|
||||||
|
|
||||||
/// bee9f7039e56cc7a
|
/// bee9f7039e56cc7a
|
||||||
var idOne:Float?
|
var idOneprice:Float?
|
||||||
var idOneAD:String = "bee9f7039e56cc7a"
|
var idOneAD:String = "bee9f7039e56cc7a"
|
||||||
var idOnex:CGFloat = UIScreen.main.bounds.width / 2
|
var idOnex:CGFloat = UIScreen.main.bounds.width / 2
|
||||||
var idOney:CGFloat = 20
|
var idOney:CGFloat = 20
|
||||||
|
|
||||||
/// 8fccdfa964b52e26
|
/// 8fccdfa964b52e26
|
||||||
var idTwo:Float?
|
var idTwoprice:Float?
|
||||||
var idTwoAD:String = "8fccdfa964b52e26"
|
var idTwoAD:String = "8fccdfa964b52e26"
|
||||||
var idTwox:CGFloat = UIScreen.main.bounds.width / 2
|
var idTwox:CGFloat = UIScreen.main.bounds.width / 2
|
||||||
var idTwoy:CGFloat = 65
|
var idTwoy:CGFloat = 65
|
||||||
|
|
||||||
/// bee9f7039e56cc7a
|
/// bee9f7039e56cc7a
|
||||||
var idThree:Float?
|
var idThreeprice:Float?
|
||||||
var idThreeAD:String = "7baed02646413e44"
|
var idThreeAD:String = "7baed02646413e44"
|
||||||
var idThreex:CGFloat = UIScreen.main.bounds.width / 2
|
var idThreex:CGFloat = UIScreen.main.bounds.width / 2
|
||||||
var idThreey:CGFloat = 110
|
var idThreey:CGFloat = 110
|
||||||
@ -73,9 +73,11 @@ class StartManager:NSObject{
|
|||||||
var IDADType:Int = 1
|
var IDADType:Int = 1
|
||||||
|
|
||||||
|
|
||||||
let loadurl = "http://192.168.41.22:6000/adtask/loaded"
|
let loadurl = "http://127.0.0.1:6000/adtask/loaded"
|
||||||
|
|
||||||
let showurl = "http://127.0.0.1:9078/adtask/show"
|
let showurl = "http://127.0.0.1:6000/adtask/show"
|
||||||
|
|
||||||
|
let closedUrl = "http://127.0.0.1:6000/adtask/closed"
|
||||||
|
|
||||||
let headers: HTTPHeaders = [
|
let headers: HTTPHeaders = [
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user