1.2.2广告策略调整

This commit is contained in:
QinFendeZhou 2024-09-27 11:20:47 +08:00
parent 87edde2707
commit 6ea3f5943c
15 changed files with 85 additions and 35 deletions

View File

@ -1923,7 +1923,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1.2.1.1;
CURRENT_PROJECT_VERSION = 1.2.2.1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RAQJ4FNZUH;
@ -1944,7 +1944,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2.1;
MARKETING_VERSION = 1.2.2;
PRODUCT_BUNDLE_IDENTIFIER = relax.offline.mp3.music;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -1969,7 +1969,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 1.2.1.1;
CURRENT_PROJECT_VERSION = 1.2.2.1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = RAQJ4FNZUH;
@ -1990,7 +1990,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2.1;
MARKETING_VERSION = 1.2.2;
PRODUCT_BUNDLE_IDENTIFIER = relax.offline.mp3.music;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";

View File

@ -102,17 +102,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
print("Failed to set type:\(error.localizedDescription)")
}
}
//
///
func setAudioStop() {
// //
// let session = AVAudioSession.sharedInstance()
// do {
// //
// try session.setActive(false)
// print("")
// } catch {
// print("Failed to set type:\(error.localizedDescription)")
// }
//
let session = AVAudioSession.sharedInstance()
do {
//
try session.setActive(false)
print("中止会话")
} catch {
print("Failed to set type:\(error.localizedDescription)")
}
}
///
func setAudioActive() {
//
let session = AVAudioSession.sharedInstance()
do {
//
try session.setCategory(.playAndRecord, mode: .default, options: [ .allowAirPlay, .allowBluetoothA2DP,.defaultToSpeaker])
try session.setActive(true)
print("恢复会话")
} catch {
print("Failed to set type:\(error.localizedDescription)")
}
}
//
private func ActiveDaysCalculation() {
@ -178,6 +191,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func applicationDidEnterBackground(_ application: UIApplication) {
//
backgroundEntryTime = Date()
//
setAudioActive()
}
//

View File

@ -90,7 +90,8 @@ var isUpDateReminder:Bool = false{
}
}
}
///UUID
public let app_UUID = UIDevice.current.identifierForVendor?.uuidString ?? UUID().uuidString
//MARK: -
//
func coreDefaultValues() {

View File

@ -85,6 +85,27 @@ class MP_ADSimpleManager: NSObject {
deinit{
NotificationCenter.default.removeObserver(self)
}
///广
func isAdMuted() {
DispatchQueue.main.async {
if MP_PlayerManager.shared.getPlayState() == .Playing {
GADMobileAds.sharedInstance().audioVideoManager.audioSessionIsApplicationManaged = true
GADMobileAds.sharedInstance().applicationMuted = true
}else {
GADMobileAds.sharedInstance().audioVideoManager.audioSessionIsApplicationManaged = false
GADMobileAds.sharedInstance().applicationMuted = false
}
}
}
///广
func isAdSounded() {
DispatchQueue.main.async {
if GADMobileAds.sharedInstance().applicationMuted == true {
GADMobileAds.sharedInstance().audioVideoManager.audioSessionIsApplicationManaged = false
GADMobileAds.sharedInstance().applicationMuted = false
}
}
}
//广
func start() {
MP_AdMobManager.shared.start()
@ -118,6 +139,7 @@ class MP_ADSimpleManager: NSObject {
guard openAdStatus, internalAdStatus else {
return
}
isAdMuted()
if platform {
if let block = completion {
MP_AppLovinManager.shared.showOpenAdIfAvailable {[weak self] ad in
@ -141,6 +163,7 @@ class MP_ADSimpleManager: NSObject {
///广
func showSearchInterstitialAdIfAvailable(completion:((AnyObject, Bool) -> Void)?) {
guard openAdStatus, internalAdStatus else {return}
isAdMuted()
if platform {
if let block = completion {
MP_AppLovinManager.shared.showSearchInterstitialAdIfAvailable { ad in
@ -165,6 +188,7 @@ class MP_ADSimpleManager: NSObject {
completion?(nil, false)
return
}
isAdMuted()
if platform {
if let block = completion {
MP_AppLovinManager.shared.showPlayInterstitialAdIfAvailable { ad in
@ -186,6 +210,7 @@ class MP_ADSimpleManager: NSObject {
///广
func showLibraryInterstitialAdIfAvailable(completion:((AnyObject) -> Void)?) {
guard openAdStatus, internalAdStatus else {return}
isAdMuted()
if platform {
if let block = completion {
MP_AppLovinManager.shared.showLibraryInterstitialAdIfAvailable { ad in

View File

@ -106,7 +106,6 @@ class MP_AdMobManager: NSObject, GADAudioVideoManagerDelegate, GADFullScreenCont
super.init()
NotificationCenter.notificationKey.add(observer: self, selector: #selector(netWorkReachableAction(_:)), notificationName: .net_switch_reachable)
GADMobileAds.sharedInstance().audioVideoManager.delegate = self
GADMobileAds.sharedInstance().audioVideoManager.audioSessionIsApplicationManaged = true
// GADMobileAds.sharedInstance().audioVideoManager.
reloadAdMobIDs()
@ -471,7 +470,7 @@ class MP_AdMobManager: NSObject, GADAudioVideoManagerDelegate, GADFullScreenCont
}
isLoadingOpenAd = true
let request = GADRequest()
MP_ADSimpleManager.shared.isAdSounded()
//广
if item.type == .Open {
//广
@ -678,6 +677,7 @@ class MP_AdMobManager: NSObject, GADAudioVideoManagerDelegate, GADFullScreenCont
///广
func layoutSearchNativeAd(in containerView: UIView) {
guard openAdStatus, internalAdStatus else {return}
MP_ADSimpleManager.shared.isAdMuted()
containerView.subviews.forEach { item in
item.removeFromSuperview()
}
@ -754,6 +754,7 @@ class MP_AdMobManager: NSObject, GADAudioVideoManagerDelegate, GADFullScreenCont
isLoadingSearchInterstitialAd = true
let item = SearchINSERTID[level]
let request = GADRequest()
MP_ADSimpleManager.shared.isAdSounded()
//广
GADInterstitialAd.load(withAdUnitID: item.identifier, request: request) { ad, error in
DispatchQueue.main.async { [weak self] in
@ -871,6 +872,7 @@ class MP_AdMobManager: NSObject, GADAudioVideoManagerDelegate, GADFullScreenCont
isLoadingPlayInterstitialAd = true
let item = PlayerINSERTID[level]
let request = GADRequest()
MP_ADSimpleManager.shared.isAdSounded()
//广
GADInterstitialAd.load(withAdUnitID: item.identifier, request: request) { ad, error in
DispatchQueue.main.async { [weak self] in
@ -1252,6 +1254,7 @@ class MP_AdMobManager: NSObject, GADAudioVideoManagerDelegate, GADFullScreenCont
///广
func layoutLibraryNativeAd(in containerView: UIView, index:Int, completion:(() -> Void)? = nil) {
guard openAdStatus, internalAdStatus else {return}
MP_ADSimpleManager.shared.isAdMuted()
containerView.subviews.forEach { item in
item.removeFromSuperview()
}
@ -1365,6 +1368,7 @@ class MP_AdMobManager: NSObject, GADAudioVideoManagerDelegate, GADFullScreenCont
isLoadingLibraryInterstitialAd = true
let item = LibraryINSERTID[level]
let request = GADRequest()
MP_ADSimpleManager.shared.isAdSounded()
//广
GADInterstitialAd.load(withAdUnitID: item.identifier, request: request) { ad, error in
DispatchQueue.main.async { [weak self] in
@ -1548,12 +1552,12 @@ class MP_AdMobManager: NSObject, GADAudioVideoManagerDelegate, GADFullScreenCont
}
//广
func audioVideoManagerWillPlayAudio(_ audioVideoManager: GADAudioVideoManager) {
accessAppdelegate.setAudioResume()
accessAppdelegate.setAudioActive()
}
//广
func audioVideoManagerDidStopPlayingAudio(_ audioVideoManager: GADAudioVideoManager) {
DispatchQueue.main.asyncAfter(deadline: .now()+0.1) {
accessAppdelegate.setAudioResume()
accessAppdelegate.setAudioActive()
}
}
//MARK: - 广 GADFullScreenContentDelegate

View File

@ -193,12 +193,11 @@ class MP_AppLovinManager: NSObject {
let initConfig = ALSdkInitializationConfiguration(sdkKey: SDKKey) { builder in
builder.mediationProvider = ALMediationProviderMAX
}
//AppLovin
ALSdk.shared().initialize(with: initConfig) { sdkConfig in
//AppLovin广
}
//
ALSdk.shared().settings.isMuted = true
ALSdk.shared().settings.userIdentifier = app_UUID
//AppLovin
ALSdk.shared().initialize(with: initConfig)
}
///广ID
func reloadAppLovinIDs() {

View File

@ -92,7 +92,7 @@ class MP_DownloadManager: NSObject {
if url.scheme == "file" {
print("用户对同一首歌删除又下载")
//
MP_NetWorkManager.shared.requestNextList("", videoId: videoId, clickTrackingParams: nil){
MP_NetWorkManager.shared.requestNextList(song.playListID ?? "", videoId: videoId, clickTrackingParams: nil){
[weak self] listSongs in
guard let self = self, let first = listSongs.first else {
return

View File

@ -544,6 +544,7 @@ class MP_PlayerManager:NSObject{
//MARK: -
//
@objc private func playerDidFinishPlaying(_ sender:Notification) {
guard let item = sender.object as? MP_AVPlayerItem else {return}
//
guard playState == .Playing else {
return
@ -584,7 +585,7 @@ class MP_PlayerManager:NSObject{
}else {
//
if let item = results.first {
if (item.level ?? 0) < level {
if (item.level) < level {
item.level = level
}
item.addTime = Date()

View File

@ -93,7 +93,7 @@ class MPPositive_MoreSongOperationsViewController: UIViewController, UIViewContr
guard let self = self else {return}
// MP_HUD.loading()
//
MP_NetWorkManager.shared.requestNextList("", videoId: browseViewModel.browseItem.videoId ?? "", clickTrackingParams: browseViewModel.browseItem.clickTrackingParams) { [weak self] listSongs in
MP_NetWorkManager.shared.requestNextList(browseViewModel.browseItem.playListId ?? "", videoId: browseViewModel.browseItem.videoId ?? "", clickTrackingParams: browseViewModel.browseItem.clickTrackingParams) { [weak self] listSongs in
guard let first = listSongs.first else {return}
let group = DispatchGroup()
group.enter()
@ -133,7 +133,7 @@ class MPPositive_MoreSongOperationsViewController: UIViewController, UIViewContr
guard let self = self else {return}
// MP_HUD.loading()
//
MP_NetWorkManager.shared.requestNextList("", videoId: searchResultItemViewModel.item.videoId ?? "", clickTrackingParams: searchResultItemViewModel.item.clickTrackingParams) { [weak self] listSongs in
MP_NetWorkManager.shared.requestNextList(searchResultItemViewModel.item.playListId ?? "", videoId: searchResultItemViewModel.item.videoId ?? "", clickTrackingParams: searchResultItemViewModel.item.clickTrackingParams) { [weak self] listSongs in
guard let first = listSongs.first else {return}
let group = DispatchGroup()
group.enter()

View File

@ -187,7 +187,7 @@ class MPPositive_OfflineSongsViewController: MPPositive_BaseViewController {
}
//
private func reloadShow() {
tableView.showMessage(offlines.count, title: "No Songs")
// tableView.showMessage(offlines.count, title: "No Songs")
switch sortType {
case 0://
showSongs = offlines.sorted(by: { item1, item2 in

View File

@ -245,7 +245,7 @@ class MPPositive_ArtistShowSongTableViewCell: UITableViewCell, PKDownloadButtonD
return
}
//
guard let videoId = itemView.browseItem.videoId else {
guard let videoId = itemView?.browseItem.videoId else {
return
}
//
@ -253,7 +253,7 @@ class MPPositive_ArtistShowSongTableViewCell: UITableViewCell, PKDownloadButtonD
//
downloadButton.state = .pending
//(Song)
MP_NetWorkManager.shared.requestNextList("", videoId: itemView.browseItem.videoId ?? "", clickTrackingParams: itemView.browseItem.clickTrackingParams){
MP_NetWorkManager.shared.requestNextList(itemView?.browseItem.playListId ?? "", videoId: itemView?.browseItem.videoId ?? "", clickTrackingParams: itemView.browseItem.clickTrackingParams){
[weak self] listSongs in
guard let self = self, let first = listSongs.first else {
//

View File

@ -237,14 +237,14 @@ class MPPositive_HomeSingleCollectionViewCell: UICollectionViewCell, PKDownloadB
// return
// }
//
guard let videoId = itemViewModel.browseItem.videoId else {
guard let videoId = itemViewModel?.browseItem.videoId else {
return
}
MP_ADSimpleManager.shared.showLibraryInterstitialAdIfAvailable(completion: nil)
//
downloadButton.state = .pending
//(Song)
MP_NetWorkManager.shared.requestNextList("", videoId: videoId, clickTrackingParams: nil){
MP_NetWorkManager.shared.requestNextList(itemViewModel?.browseItem.playListId ?? "", videoId: videoId, clickTrackingParams: nil){
[weak self] listSongs in
guard let self = self, let first = listSongs.first else {
//

View File

@ -270,14 +270,14 @@ class MPPositive_MusicItemShowTableViewCell: UITableViewCell, PKDownloadButtonDe
return
}
//
guard let videoId = itemView.browseItem.videoId else {
guard let videoId = itemView?.browseItem.videoId else {
return
}
MP_ADSimpleManager.shared.showLibraryInterstitialAdIfAvailable(completion: nil)
//
downloadButton.state = .pending
//(Song)
MP_NetWorkManager.shared.requestNextList("", videoId: videoId, clickTrackingParams: nil){
MP_NetWorkManager.shared.requestNextList(itemView?.browseItem.playListId ?? "", videoId: videoId, clickTrackingParams: nil){
[weak self] listSongs in
guard let self = self, let first = listSongs.first else {
//

View File

@ -297,17 +297,22 @@ class MPPositive_SearchResultShowTableViewCell: UITableViewCell, PKDownloadButto
return
}
var videoId:String?
var playListId:String?
if let itemView = itemView {
videoId = itemView.item.videoId
playListId = itemView.item.playListId
}
if let songViewModel = songViewModel {
videoId = songViewModel.collectionSong.videoId
playListId = ""
}
if let loadViewModel = loadViewModel {
videoId = loadViewModel.loadItem.videoId
playListId = loadViewModel.loadItem.playListID
}
if let videoModel = videoModel {
videoId = videoModel.videoId
playListId = ""
}
//
guard let videoId = videoId else {
@ -318,7 +323,7 @@ class MPPositive_SearchResultShowTableViewCell: UITableViewCell, PKDownloadButto
//
downloadButton.state = .pending
//(Song)
MP_NetWorkManager.shared.requestNextList("", videoId: videoId, clickTrackingParams: nil){
MP_NetWorkManager.shared.requestNextList(playListId ?? "", videoId: videoId, clickTrackingParams: nil){
[weak self] listSongs in
guard let self = self, let first = listSongs.first else {
//