Wallpaper_Home/wallpaper_project/Home/C/WA_DetailsVC.swift
忆海16 5ff1070967 mtg
2024-07-23 11:44:01 +08:00

873 lines
36 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// WA_DetailsVC.swift
// wallpaper_project
import UIKit
import SDWebImage
import Photos
import SVProgressHUD
import AppLovinSDK
import FirebaseAnalytics
import Alamofire
import FirebaseRemoteConfig
import MTGSDKNewInterstitial
import MTGSDKBidding
import MTGSDK
class WA_DetailsVC: WA_RootVC {
@IBOutlet weak var bgView: UIView!
@IBOutlet weak var backBtn: UIButton!
@IBOutlet weak var setBtn: UIButton!
@IBOutlet weak var preimageV: UIImageView!
var model = WA_3DModel()
var modeltype = WallpaperData()
var preV:UIView?
let activityView = UIActivityIndicatorView()
var type:Int = 0
var interstitialAd: MAInterstitialAd!
var retryAttempt = 0.0
var isback:Bool = false
var remoteConfig: RemoteConfig!
var isadshow:Bool = false
var bidToken:String?
var newInterstitialAdManager:MTGNewInterstitialBidAdManager?
override func viewDidLoad() {
super.viewDidLoad()
// self.createInterstitialAd()
// interstitialAd.load()
if type == 1{
let imageURL = URL(string: model.preview ?? "")
preimageV.sd_setImage(with: imageURL, placeholderImage: UIImage(named: "Rectangle"))
}else{
let imageURL = URL(string: modeltype.source ?? "")
preimageV.sd_setImage(with: imageURL, placeholderImage: UIImage(named: "Rectangle"))
}
Analytics.logEvent("in_Details", parameters: nil)
setBtn.layer.cornerRadius = 10
// UIView
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(viewTapped))
preimageV.isUserInteractionEnabled = true
preimageV.addGestureRecognizer(tapGesture)
activityView.center = CGPoint(x: self.view.center.x, y: self.view.center.y - kSafeArea_Top - 44)
//
activityView.hidesWhenStopped = true
activityView.color = .black;
activityView.style = UIActivityIndicatorView.Style.whiteLarge
self.view.addSubview(activityView)
backBtn.layer.cornerRadius = 20
if type == 1{
let model1 = WA_3DModel()
model1.preview = self.model.preview
model1.title = self.model.title
model1.thumbnail = self.model.thumbnail
model1.is_free = self.model.is_free
model1.category = self.model.category
model1.id = self.model.id
model1.cnt_like = self.model.cnt_like
HistoryManager.shared.addHistoryItem(item: model1)
}else{
let model1 = WallpaperData()
model1.original = self.modeltype.original
model1.previewThumb = self.modeltype.previewThumb
model1.source = self.modeltype.source
model1.banner = self.modeltype.banner
HistoryjpgManager.shared.addHistoryItem(item: model1)
}
}
@IBAction func setting(_ sender: Any) {
Analytics.logEvent("touch_savephoto", parameters: nil)
self.activityView.startAnimating()
saveImageToPhotoLibrary()
//
// if self.isadshow == true{
// DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.5) {
// if self.interstitialAd.isReady {
// self.interstitialAd.show()
// Analytics.logEvent("details_load_success", parameters: nil)
// self.setPostSHOW()
// let logMessage = """
// deviceId: \(StartManager.shared.devicID ?? "")
// localIp: \(StartManager.shared.localIP ?? "")
// "deviceId": \(StartManager.shared.devicID ?? ""),
// "localIp": \(StartManager.shared.localIP ?? ""),
// "remoteIp": \(StartManager.shared.publicIP ?? ""),
// "linkId": "",
// "packageName": "com.wallpapaer.hd.live.app",
// "gaid": \(StartManager.shared.idfaid ?? ""),
// "dataId": "",
// "shelfNumber": "",
// "succeed": \(StartManager.shared.succeed),
// "loadTime": \(StartManager.shared.loadTime ?? 0),
// "adPlatform": \(StartManager.shared.adPlatform ?? ""),
// "countryCode": \(StartManager.shared.countryCode ?? ""),
// "adId": \(StartManager.shared.adId ?? ""),
// "platformResponseTime": \(StartManager.shared.platformResponseTime ?? 0.0),
// "getIpResponseTime": \(StartManager.shared.getIpResponseTime ?? 0.0),
// "ecpm": \(StartManager.shared.ecpm ?? 0.0),
// "dsp": \(StartManager.shared.dsp ?? ""),
// "network": \(StartManager.shared.network ?? "")
// """
// AppDelegate.shared.addLogMessage(logMessage)
// }else{
// print("-------广")
// Analytics.logEvent("details_load_fail", parameters: nil)
// DispatchQueue.global().asyncAfter(deadline: .now() + 1.5) {
// DispatchQueue.main.asyncAfter(deadline: .now() + 0){
// self.activityView.stopAnimating()
// // self.view.makeToast("Save Success", duration: 1.5, position: .center)
// // UIAlertController
// let alertController = UIAlertController(title: "Successfully saved", message: "Do you need to set up a tutorial", preferredStyle: .alert)
//
// //
// alertController.addAction(UIAlertAction(title: "cancel", style: .cancel, handler: nil))
//
// //
// alertController.addAction(UIAlertAction(title: "Need", style: .default, handler: { action in
// //
// // print("")
// let vc = WA_TipVC()
// self.present(vc, animated: true)
// }))
//
// // present
// self.present(alertController, animated: true, completion: nil)
//
// }
// }
// }
// }
//
// }else{
// Analytics.logEvent("details_load_fail", parameters: nil)
// DispatchQueue.global().asyncAfter(deadline: .now() + 1.5) {
// DispatchQueue.main.asyncAfter(deadline: .now() + 0){
// self.activityView.stopAnimating()
// // self.view.makeToast("Save Success", duration: 1.5, position: .center)
// // UIAlertController
// let alertController = UIAlertController(title: "Successfully saved", message: "Do you need to set up a tutorial", preferredStyle: .alert)
//
// //
// alertController.addAction(UIAlertAction(title: "cancel", style: .cancel, handler: nil))
//
// //
// alertController.addAction(UIAlertAction(title: "Need", style: .default, handler: { action in
// //
// // print("")
// let vc = WA_TipVC()
// self.present(vc, animated: true)
// }))
//
// // present
// self.present(alertController, animated: true, completion: nil)
// }
// }
// }
let issureready = newInterstitialAdManager?.isAdReady()
if self.isadshow == true{
if ((issureready) != nil) {
newInterstitialAdManager?.show(from: self)
self.setPostSHOW()
}else{
DispatchQueue.global().asyncAfter(deadline: .now() + 1.5) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0){
self.activityView.stopAnimating()
// self.view.makeToast("Save Success", duration: 1.5, position: .center)
// UIAlertController
let alertController = UIAlertController(title: "Successfully saved", message: "Do you need to set up a tutorial", preferredStyle: .alert)
//
alertController.addAction(UIAlertAction(title: "cancel", style: .cancel, handler: nil))
//
alertController.addAction(UIAlertAction(title: "Need", style: .default, handler: { action in
//
// print("")
let vc = WA_TipVC()
self.present(vc, animated: true)
}))
// present
self.present(alertController, animated: true, completion: nil)
}
}
}
}else{
DispatchQueue.global().asyncAfter(deadline: .now() + 1.5) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0){
self.activityView.stopAnimating()
// self.view.makeToast("Save Success", duration: 1.5, position: .center)
// UIAlertController
let alertController = UIAlertController(title: "Successfully saved", message: "Do you need to set up a tutorial", preferredStyle: .alert)
//
alertController.addAction(UIAlertAction(title: "cancel", style: .cancel, handler: nil))
//
alertController.addAction(UIAlertAction(title: "Need", style: .default, handler: { action in
//
// print("")
let vc = WA_TipVC()
self.present(vc, animated: true)
}))
// present
self.present(alertController, animated: true, completion: nil)
}
}
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.navigationBar.isHidden = true
// self.createInterstitialAd()
// Remote Config
remoteConfig = RemoteConfig.remoteConfig()
//
let settings = RemoteConfigSettings()
settings.minimumFetchInterval = 0
remoteConfig.configSettings = settings
// Fetch
remoteConfig.setDefaults(fromPlist: "isopen")
// Fetch
let param = MTGBiddingRequestParameter(placementId: "1636950", unitId: "3501963", basePrice: nil)
MTGBiddingRequest.getBidWith(param) { bidResponse in
if bidResponse.success{
self.bidToken = bidResponse.bidToken
bidResponse.notifyWin()
self.newInterstitialAdManager = MTGNewInterstitialBidAdManager(placementId: "1636950", unitId: "3501963", delegate: self)
self.newInterstitialAdManager?.loadAd(withBidToken:self.bidToken!)
self.fetchRemoteConfig()
}else{
// WA_TabbarCommon.TabBarController()
}
}
}
///广
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 saveImageToPhotoLibrary() {
guard let image = self.preimageV.image else {
print("找不到要保存的图片")
SVProgressHUD.showInfo(withStatus: "Can't find the picture to save")
DispatchQueue.global().asyncAfter(deadline: .now() + 2.0) {
SVProgressHUD.dismiss()
}
return
}
PHPhotoLibrary.requestAuthorization { status in
switch status {
case .authorized:
self.saveImage(image: image)
case .denied, .restricted:
print("用户拒绝了访问相册权限")
SVProgressHUD.showInfo(withStatus: "Album access denied")
DispatchQueue.global().asyncAfter(deadline: .now() + 2.0) {
SVProgressHUD.dismiss()
}
case .notDetermined:
print("用户尚未选择是否允许访问相册")
SVProgressHUD.showInfo(withStatus: "You have not chosen whether to allow access to the album")
DispatchQueue.global().asyncAfter(deadline: .now() + 2.0) {
SVProgressHUD.dismiss()
}
@unknown default:
break
}
}
}
func saveImage(image: UIImage) {
PHPhotoLibrary.shared().performChanges({
//
PHAssetChangeRequest.creationRequestForAsset(from: image)
}) { success, error in
if success {
print("图片保存成功")
} else if let error = error {
print("图片保存失败:\(error.localizedDescription)")
SVProgressHUD.showError(withStatus: "Image saving failed:\(error.localizedDescription)")
DispatchQueue.global().asyncAfter(deadline: .now() + 2.0) {
SVProgressHUD.dismiss()
}
}
}
}
@IBAction func collectBtn(_ sender: Any) {
Analytics.logEvent("touch_collect", parameters: nil)
if isLoggedIn(){
if type == 1{
let model1 = WA_3DModel()
model1.preview = self.model.preview
model1.title = self.model.title
model1.thumbnail = self.model.thumbnail
model1.is_free = self.model.is_free
model1.category = self.model.category
model1.id = self.model.id
model1.cnt_like = self.model.cnt_like
sc4kManager.shared.addHistoryItem(item: model1)
}else{
let model1 = WallpaperData()
model1.original = self.modeltype.original
model1.previewThumb = self.modeltype.previewThumb
model1.source = self.modeltype.source
model1.banner = self.modeltype.banner
scjpgManager.shared.addHistoryItem(item: model1)
}
SVProgressHUD.showInfo(withStatus: "Collection successful")
DispatchQueue.global().asyncAfter(deadline: .now() + 2.0) {
SVProgressHUD.dismiss()
}
}else{
let vc = WA_LoginVC()
navigationController?.pushViewController(vc, animated: true)
}
}
@IBAction func previewBtn(_ sender: Any) {
Analytics.logEvent("touch_preview", parameters: nil)
UIView.animate(withDuration: 0.5, animations: {
self.bgView.frame.origin.y += 0
self.bgView.alpha = 0
self.backBtn.isHidden = true
})
showView()
}
//
@objc func viewTapped() {
// UIView
if bgView.frame.origin.y == UIScreen.main.bounds.height - bgView.frame.height {
// UIView
UIView.animate(withDuration: 0.5, animations: {
self.bgView.frame.origin.y += self.bgView.frame.height
self.bgView.alpha = 0
self.backBtn.isHidden = true
})
} else {
self.backBtn.isHidden = false
// UIView
UIView.animate(withDuration: 0.5, animations: {
self.bgView.frame.origin.y -= self.bgView.frame.height
self.bgView.alpha = 1
})
}
}
func showView() {
//
let previewView = Bundle.main.loadNibNamed("WA_PreView", owner: nil, options: nil)?.first as! WA_PreView
previewView.flashView.layer.cornerRadius = 25
previewView.cameraV.layer.cornerRadius = 25
previewView.touchBlock = {
self.backBtn.isHidden = false
// UIView
UIView.animate(withDuration: 0.5, animations: {
self.bgView.frame.origin.y -= 0
self.bgView.alpha = 1
})
}
view.addSubview(previewView)
//
previewView.frame.origin.x = -previewView.frame.width
//
UIView.animate(withDuration: 1.0) {
//
previewView.frame = self.view.frame
}
}
@IBAction func shareBtn(_ sender: Any) {
Analytics.logEvent("touch_share", parameters: nil)
self.activityView.startAnimating()
//
guard let image = self.preimageV.image else {
SVProgressHUD.showInfo(withStatus: "Can't find the image to share")
DispatchQueue.global().asyncAfter(deadline: .now() + 2.0) {
SVProgressHUD.dismiss()
}
print("找不到要分享的图片")
return
}
//
let items: [Any] = [image]
// UIActivityViewController
let activityViewController = UIActivityViewController(activityItems: items, applicationActivities: nil)
// UIActivityViewController
activityViewController.modalPresentationStyle = .popover
// iPad UIActivityViewController
if let popoverController = activityViewController.popoverPresentationController {
popoverController.sourceView = self.view
popoverController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
popoverController.permittedArrowDirections = []
}
//
self.present(activityViewController, animated: true, completion: nil)
DispatchQueue.main.asyncAfter(deadline: .now() + 0){
self.activityView.stopAnimating()
}
}
@IBAction func back(_ sender: Any) {
isback = true
// if self.isadshow == true{
// DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.5) {
// if self.interstitialAd.isReady {
// self.interstitialAd.show()
// Analytics.logEvent("details_load_success", parameters: nil)
// self.setPostSHOW()
// let logMessage = """
// deviceId: \(StartManager.shared.devicID ?? "")
// localIp: \(StartManager.shared.localIP ?? "")
// "deviceId": \(StartManager.shared.devicID ?? ""),
// "localIp": \(StartManager.shared.localIP ?? ""),
// "remoteIp": \(StartManager.shared.publicIP ?? ""),
// "linkId": "",
// "packageName": "com.wallpapaer.hd.live.app",
// "gaid": \(StartManager.shared.idfaid ?? ""),
// "dataId": "",
// "shelfNumber": "",
// "succeed": \(StartManager.shared.succeed),
// "loadTime": \(StartManager.shared.loadTime ?? 0),
// "adPlatform": \(StartManager.shared.adPlatform ?? ""),
// "countryCode": \(StartManager.shared.countryCode ?? ""),
// "adId": \(StartManager.shared.adId ?? ""),
// "platformResponseTime": \(StartManager.shared.platformResponseTime ?? 0.0),
// "getIpResponseTime": \(StartManager.shared.getIpResponseTime ?? 0.0),
// "ecpm": \(StartManager.shared.ecpm ?? 0.0),
// "dsp": \(StartManager.shared.dsp ?? ""),
// "network": \(StartManager.shared.network ?? "")
// """
// AppDelegate.shared.addLogMessage(logMessage)
// }else{
// self.navigationController?.popViewController(animated: true)
// }
// }
// }else{
// self.navigationController?.popViewController(animated: true)
// }
let issureready = newInterstitialAdManager?.isAdReady()
if self.isadshow == true{
if ((issureready) != nil) {
newInterstitialAdManager?.show(from: self)
}else{
self.navigationController?.popViewController(animated: true)
}
}else{
self.navigationController?.popViewController(animated: true)
}
}
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.wallpapaer.hd.live.app",
"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.wallpapaer.hd.live.app",
"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 WA_DetailsVC:MTGNewInterstitialBidAdDelegate{
// func newInterstitialBidAdShowSuccess(_ adManager: MTGNewInterstitialBidAdManager) {
// print("广")
// }
func newInterstitialBidAdResourceLoadSuccess(_ adManager: MTGNewInterstitialBidAdManager) {
print("资源加载成功,表示可播放状态")
}
func newInterstitialBidAdLoadSuccess(_ adManager: MTGNewInterstitialBidAdManager) {
print("广告加载成功")
StartManager.shared.succeed = true
// StartManager.shared.loadTime = self.adLoadTime
StartManager.shared.adPlatform = "mbridge"
StartManager.shared.countryCode = ALSdk.shared().configuration.countryCode
StartManager.shared.adId = "3501963"
StartManager.shared.platformResponseTime = 0
// StartManager.shared.ecpm = Float(ad.revenue)
StartManager.shared.dsp = ""
StartManager.shared.network = ""
setPostload()
}
func newInterstitialBidAdLoadFail(_ error: any Error, adManager: MTGNewInterstitialBidAdManager) {
print("-----\(error)")
// print(" 广")
}
func newInterstitialBidAdShowSuccess(withBidToken bidToken: String, adManager: MTGNewInterstitialBidAdManager) {
print("广告展示成功")
}
func newInterstitialBidAdShowFail(_ error: any Error, adManager: MTGNewInterstitialBidAdManager) {
print("广告展示失败")
if isback == true{
self.navigationController?.popViewController(animated: true)
}else{
DispatchQueue.global().asyncAfter(deadline: .now() + 1.5) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0){
self.activityView.stopAnimating()
// self.view.makeToast("Save Success", duration: 1.5, position: .center)
// UIAlertController
let alertController = UIAlertController(title: "Successfully saved", message: "Do you need to set up a tutorial", preferredStyle: .alert)
//
alertController.addAction(UIAlertAction(title: "cancel", style: .cancel, handler: nil))
//
alertController.addAction(UIAlertAction(title: "Need", style: .default, handler: { action in
//
// print("")
let vc = WA_TipVC()
self.present(vc, animated: true)
}))
// present
self.present(alertController, animated: true, completion: nil)
}
}
}
}
func newInterstitialBidAdPlayCompleted(_ adManager: MTGNewInterstitialBidAdManager) {
print("广告播放完全播放回调")
}
func newInterstitialBidAdEndCardShowSuccess(_ adManager: MTGNewInterstitialBidAdManager) {
print("视频播放完成后展示结果页")
}
func newInterstitialBidAdClicked(_ adManager: MTGNewInterstitialBidAdManager) {
print("广告被点击")
}
// 广
func newInterstitialBidAdDidClosed(_ adManager: MTGNewInterstitialBidAdManager) {
print("广告被关闭")
if isback == true{
self.navigationController?.popViewController(animated: true)
}else{
DispatchQueue.global().asyncAfter(deadline: .now() + 1.5) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0){
self.activityView.stopAnimating()
// self.view.makeToast("Save Success", duration: 1.5, position: .center)
// UIAlertController
let alertController = UIAlertController(title: "Successfully saved", message: "Do you need to set up a tutorial", preferredStyle: .alert)
//
alertController.addAction(UIAlertAction(title: "cancel", style: .cancel, handler: nil))
//
alertController.addAction(UIAlertAction(title: "Need", style: .default, handler: { action in
//
// print("")
let vc = WA_TipVC()
self.present(vc, animated: true)
}))
// present
self.present(alertController, animated: true, completion: nil)
}
}
}
}
}
//extension WA_DetailsVC: MAAdDelegate
//{
// func createInterstitialAd()
// {
// interstitialAd = MAInterstitialAd(adUnitIdentifier: "880a042774979c3c")
// 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 = "880a042774979c3c"
// 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 isback == true{
// self.navigationController?.popViewController(animated: true)
// }else{
// DispatchQueue.global().asyncAfter(deadline: .now() + 1.5) {
// DispatchQueue.main.asyncAfter(deadline: .now() + 0){
// self.activityView.stopAnimating()
// // self.view.makeToast("Save Success", duration: 1.5, position: .center)
// // UIAlertController
// let alertController = UIAlertController(title: "Successfully saved", message: "Do you need to set up a tutorial", preferredStyle: .alert)
//
// //
// alertController.addAction(UIAlertAction(title: "cancel", style: .cancel, handler: nil))
//
// //
// alertController.addAction(UIAlertAction(title: "Need", style: .default, handler: { action in
// //
// // print("")
// let vc = WA_TipVC()
// self.present(vc, animated: true)
// }))
//
// // present
// self.present(alertController, animated: true, completion: nil)
//
// }
// }
//
// }
//
// }
//
// func didFail(toDisplay ad: MAAd, withError error: MAError)
// {
// // Interstitial ad failed to display. We recommend loading the next ad
// interstitialAd.load()
// }
//}