diff --git a/WOKA.xcodeproj/project.pbxproj b/WOKA.xcodeproj/project.pbxproj
index 38d0635..4f33547 100644
--- a/WOKA.xcodeproj/project.pbxproj
+++ b/WOKA.xcodeproj/project.pbxproj
@@ -2895,7 +2895,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = WOKA/WOKA.entitlements;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 1;
+ CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = 4S9A74ZB6H;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
@@ -2939,7 +2939,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = WOKA/WOKA.entitlements;
CODE_SIGN_STYLE = Automatic;
- CURRENT_PROJECT_VERSION = 1;
+ CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = 4S9A74ZB6H;
ENABLE_USER_SCRIPT_SANDBOXING = NO;
GENERATE_INFOPLIST_FILE = YES;
diff --git a/WOKA/Audio Books/AudioBookHomeVM.swift b/WOKA/Audio Books/AudioBookHomeVM.swift
index 1709957..39a6880 100644
--- a/WOKA/Audio Books/AudioBookHomeVM.swift
+++ b/WOKA/Audio Books/AudioBookHomeVM.swift
@@ -37,7 +37,8 @@ class AudioBookHomeVM{
startShimmer()
setupCell()
getShowListing()
-
+ checkAds()
+
}
func checkAds(){
@@ -135,7 +136,6 @@ class AudioBookHomeVM{
self.vc.continueWatchingStack.isHidden = true
case 1:
Utilities.dismissProgressHUD()
- checkAds()
guard let data = data.data?.result else{return}
if data.count == 0{
@@ -264,7 +264,8 @@ class AudioBookHomeVM{
guard let isFav else{return}
if isFav == true {
// if is fav then remove it
- LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [weak self] isDone in
+ guard let self else{return}
if isDone{
if let showListIndex = audioListData.firstIndex(where: { $0.id == postID }){
audioListData[showListIndex].markAsFavourite = false
@@ -298,8 +299,9 @@ class AudioBookHomeVM{
}
}
}else{
- LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [weak self] isDone in
if isDone{
+ guard let self else{return}
if let showListIndex = audioListData.firstIndex(where: { $0.id == postID }){
audioListData[showListIndex].markAsFavourite = true
vc.audioListingTableView.reloadRows(at: [IndexPath(row: showListIndex, section: 0)],with: .none)
@@ -337,7 +339,8 @@ class AudioBookHomeVM{
guard let isLiked else{return}
if isLiked{
// Unlike
- LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self.vc) { [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self.vc) { [weak self] isDone in
+ guard let self else{return}
if isDone{
if let showListIndex = audioListData.firstIndex(where: { $0.id == postID }){
audioListData[showListIndex].isLiked = false
@@ -367,7 +370,8 @@ class AudioBookHomeVM{
}
}else{
//Like
- LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self.vc){ [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self.vc){ [weak self] isDone in
+ guard let self else{return}
if isDone{
if let showListIndex = audioListData.firstIndex(where: { $0.id == postID }){
audioListData[showListIndex].isLiked = true
diff --git a/WOKA/Constants K/GoogleAdIDs.swift b/WOKA/Constants K/GoogleAdIDs.swift
index 63fead9..215cdef 100644
--- a/WOKA/Constants K/GoogleAdIDs.swift
+++ b/WOKA/Constants K/GoogleAdIDs.swift
@@ -27,6 +27,8 @@ extension K{
static let myListNotifications = "ca-app-pub-5699008063638916/8922510426"
+ static let blogs = "ca-app-pub-5699008063638916/8441860789"
+
//
//
//
diff --git a/WOKA/DataSync&AdsManage/PersistentStorage.swift b/WOKA/DataSync&AdsManage/PersistentStorage.swift
index 6810a30..c5c9e8b 100644
--- a/WOKA/DataSync&AdsManage/PersistentStorage.swift
+++ b/WOKA/DataSync&AdsManage/PersistentStorage.swift
@@ -286,7 +286,9 @@ final class PersistentStorage
return
} else{
// send data again to server
- sendDataToServer()
+ if result.count != 0{
+ sendDataToServer(isLogout: isLogout)
+ }
print("Data sent Again.")
}
@@ -424,7 +426,9 @@ extension PersistentStorage{
return
}else{
// send ads data again to server
- sendAdsData()
+ if result.count != 0{
+ sendAdsData()
+ }
print("Ads Data sent Again.")
}
diff --git a/WOKA/Games/ViewModel/GamesListVM.swift b/WOKA/Games/ViewModel/GamesListVM.swift
index af51779..d43d8ac 100644
--- a/WOKA/Games/ViewModel/GamesListVM.swift
+++ b/WOKA/Games/ViewModel/GamesListVM.swift
@@ -213,7 +213,8 @@ class GamesListVM{
case .favourite:
guard let isFav = data.markAsFavourite ,let postID = data.id,let postType = data.contentMoreDetails?.first?.postType else{return}
if isFav == true {
- LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [weak self] isDone in
+ guard let self else{return}
if isDone{
gameData[index].markAsFavourite = false
vc.gamesListingTableView.reloadRows(at: [IndexPath(row: index, section: 0)],with: .none)
@@ -228,7 +229,8 @@ class GamesListVM{
}
}
}else{
- LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [weak self] isDone in
+ guard let self else{return}
if isDone{
gameData[index].markAsFavourite = true
vc.gamesListingTableView.reloadRows(at: [IndexPath(row: index, section: 0)],with: .none)
@@ -246,7 +248,8 @@ class GamesListVM{
case .liked:
guard let isLiked = data.isLiked ,let postID = data.id,let postType = data.contentMoreDetails?.first?.postType else{return}
if isLiked{
- LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self.vc) { [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self.vc) { [weak self] isDone in
+ guard let self else{return}
if isDone{
gameData[index].isLiked = false
gameData[index].likesCount! -= 1
@@ -264,7 +267,8 @@ class GamesListVM{
}
}
}else{
- LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self.vc){ [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self.vc){ [weak self] isDone in
+ guard let self else{return}
if isDone{
gameData[index].isLiked = true
gameData[index].likesCount! += 1
diff --git a/WOKA/Home/Controller/MyListVC.swift b/WOKA/Home/Controller/MyListVC.swift
index fea5d0b..1ae7b29 100644
--- a/WOKA/Home/Controller/MyListVC.swift
+++ b/WOKA/Home/Controller/MyListVC.swift
@@ -41,6 +41,7 @@ class MyListVC: UIViewController{
@IBOutlet weak var shimmerStack: UIStackView!
@IBOutlet var shimmerView: [ShimmerEffectView]!
@IBOutlet weak var adView: UIView!
+ @IBOutlet weak var adHeight: NSLayoutConstraint!
var vm = MyListVM()
@@ -61,7 +62,8 @@ class MyListVC: UIViewController{
}
@objc func refresh(_ sender: AnyObject) {
- Timer.scheduledTimer(withTimeInterval: 1, repeats: false) { [unowned self] _ in
+ Timer.scheduledTimer(withTimeInterval: 1, repeats: false) { [weak self] _ in
+ guard let self else{return}
vm.getFavouriteListing()
}
}
@@ -807,10 +809,9 @@ extension MyListVC : UICollectionViewDelegateFlowLayout{
// MARK: - Google Ad Banner Delegate
extension MyListVC : GADBannerViewDelegate{
+
func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
- adView.isHidden = false
bannerView.alpha = 0
- bannerView.backgroundColor = #colorLiteral(red: 0.01960784314, green: 0, blue: 0.2196078431, alpha: 1)
UIView.animate(withDuration: 0.2, animations: {
bannerView.alpha = 1
})
@@ -818,6 +819,11 @@ extension MyListVC : GADBannerViewDelegate{
}
func bannerView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: Error) {
+ UIView.animate(withDuration: 0.2, animations: { [weak self] in
+ guard let self else{return}
+ bannerView.alpha = 0
+ adHeight.constant = 0
+ })
print("bannerView:didFailToReceiveAdWithError: \(error.localizedDescription)")
}
diff --git a/WOKA/Home/Home.storyboard b/WOKA/Home/Home.storyboard
index 65d18cb..6b8b92e 100644
--- a/WOKA/Home/Home.storyboard
+++ b/WOKA/Home/Home.storyboard
@@ -1071,312 +1071,307 @@
-
-
+
+
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1474,15 +1469,12 @@
-
-
+
+
-
+
-
-
-
@@ -1490,11 +1482,8 @@
-
+
-
-
-
@@ -1502,11 +1491,8 @@
-
+
-
-
-
@@ -1523,10 +1509,9 @@
-
-
-
+
+
@@ -1534,24 +1519,29 @@
-
+
+
+
+
-
+
+
+
@@ -1667,10 +1657,10 @@
-
+
-
+
diff --git a/WOKA/Home/ViewModel/MyListVM.swift b/WOKA/Home/ViewModel/MyListVM.swift
index 8321c29..3f9f18c 100644
--- a/WOKA/Home/ViewModel/MyListVM.swift
+++ b/WOKA/Home/ViewModel/MyListVM.swift
@@ -37,6 +37,59 @@ class MyListVM{
startShimmer(load: false)
return
}
+
+ /*
+ First check if webSeries ad is present via slug, then check for Local Ads, if not then check google ads.
+ */
+ if let adsData = AuthFunc.shareInstance.adsData, let myListAd = adsData.result?.filter({$0.slug == AdsEnum.myList.rawValue}).first{
+
+ // check if ads data contains LocalAD for webseries
+ if let advertisement = myListAd.advertisement,let bannerImage = advertisement.bannerImage{
+// vc.imageAdView.imageURL(bannerImage, color: .white)
+// vc.imageAdView.alpha = 0
+ let height = UIScreen.main.bounds.width * 0.192
+ vc.adHeight.constant = height
+
+ let imageView = UIImageView()
+
+ // Set the image you want to display
+ imageView.imageURL(bannerImage, color: .white)
+
+ // Enable auto-layout
+ imageView.translatesAutoresizingMaskIntoConstraints = false
+
+ // Add the UIImageView to the view
+ vc.adView.addSubview(imageView)
+
+ // Set UIImageView to match the size of the parent UIView
+ NSLayoutConstraint.activate([
+ imageView.leadingAnchor.constraint(equalTo: vc.adView.leadingAnchor),
+ imageView.trailingAnchor.constraint(equalTo: vc.adView.trailingAnchor),
+ imageView.topAnchor.constraint(equalTo: vc.adView.topAnchor),
+ imageView.bottomAnchor.constraint(equalTo: vc.adView.bottomAnchor)
+ ])
+ imageView.contentMode = .scaleAspectFit
+ UIView.animate(withDuration: 0.2, animations: { [weak self] in
+ guard let self else{return}
+ vc.adView.alpha = 1
+ })
+
+ vc.adView.addTapGesture {
+ if let adID = myListAd.id{
+ PersistentStorage.shared.addAdsCount(adID: adID ,clicks: 1)
+ }
+ if let adLink = myListAd.advertisement?.adLink ,let url = URL(string: adLink), UIApplication.shared.canOpenURL(url) {
+ UIApplication.shared.open(url)
+ }
+ }
+ }else if myListAd.googleAd != nil{
+ //setup google banner ads.
+ vc.adHeight.constant = 90
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: {
+ AdReusable.sharedInstance.setupBannerAd(bannerView: self.bottomBanner, in: self.vc.adView, adUnitID: K.GoogleAdIDs.myListNotifications, viewController: self.vc, height: 6,width: 0)
+ })
+ }
+ }
setupCell()
startShimmer(load: true)
@@ -59,18 +112,7 @@ class MyListVM{
shimmer.startShimmer()
}else{
shimmer.stopShimmer()
- /*
- If ads found then only load it or else directly append the data and reload
- */
- if let adsData = AuthFunc.shareInstance.adsData{
- // check if ads data contains ad for webseries
- if let myListAd = adsData.result?.filter({$0.slug == AdsEnum.myList.rawValue}).first, myListAd.googleAd != nil{
- //setup google banner ads.
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: {
- AdReusable.sharedInstance.setupBannerAd(bannerView: self.bottomBanner, in: self.vc.adView, adUnitID: K.GoogleAdIDs.myListNotifications, viewController: self.vc, height: 6,width: 0)
- })
- }
- }
+
}
}
}
diff --git a/WOKA/Karaoke/ViewModel/KaraokeListingVM.swift b/WOKA/Karaoke/ViewModel/KaraokeListingVM.swift
index 0344c83..781c49b 100644
--- a/WOKA/Karaoke/ViewModel/KaraokeListingVM.swift
+++ b/WOKA/Karaoke/ViewModel/KaraokeListingVM.swift
@@ -243,7 +243,8 @@ class KaraokeListingVM{
case .favourite:
guard let isFav else{return}
if isFav == true {
- LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [weak self] isDone in
+ guard let self else{return}
if isDone{
if let showListIndex = karaokeListData.firstIndex(where: { $0.id == postID }){
karaokeListData[showListIndex].markAsFavourite = false
@@ -278,7 +279,8 @@ class KaraokeListingVM{
}
}
}else{
- LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: 0, vc: self.vc) { [weak self] isDone in
+ guard let self else{return}
if isDone{
if let showListIndex = karaokeListData.firstIndex(where: { $0.id == postID }){
karaokeListData[showListIndex].markAsFavourite = true
@@ -318,7 +320,8 @@ class KaraokeListingVM{
case .liked:
guard let isLiked else{return}
if isLiked{
- LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self.vc) { [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self.vc) { [weak self] isDone in
+ guard let self else{return}
if isDone{
if let showListIndex = karaokeListData.firstIndex(where: { $0.id == postID }){
karaokeListData[showListIndex].isLiked = false
@@ -348,7 +351,8 @@ class KaraokeListingVM{
}
}
}else{
- LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self.vc){ [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self.vc){ [weak self] isDone in
+ guard let self else{return}
if isDone{
if let showListIndex = karaokeListData.firstIndex(where: { $0.id == postID }){
karaokeListData[showListIndex].isLiked = true
diff --git a/WOKA/Main/AuthFunc/AuthFunc.swift b/WOKA/Main/AuthFunc/AuthFunc.swift
index 6d0e46f..67fb4a8 100644
--- a/WOKA/Main/AuthFunc/AuthFunc.swift
+++ b/WOKA/Main/AuthFunc/AuthFunc.swift
@@ -32,6 +32,7 @@ enum AdsEnum : String{
case webSeriesVideoAd = "web-series-video-ad"
case more = "more"
case myList = "my-list"
+ case shopListing = "shop-listing"
}
class AuthFunc{
diff --git a/WOKA/Shop/Shop.storyboard b/WOKA/Shop/Shop.storyboard
index 2a5cea0..fe1f2ce 100644
--- a/WOKA/Shop/Shop.storyboard
+++ b/WOKA/Shop/Shop.storyboard
@@ -122,17 +122,17 @@
-
+
-
+
-
+
-
+
@@ -299,19 +299,19 @@
-
+
-
+
-
+
@@ -718,7 +724,7 @@
-
+
@@ -771,6 +777,8 @@
+
+
@@ -792,10 +800,22 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -833,14 +853,16 @@
-
+
+
+
-
-
-
+
+
+
@@ -1193,8 +1215,8 @@
-
-
+
+
@@ -1204,10 +1226,12 @@
-
-
-
-
+
+
+
+
+
+
@@ -1263,6 +1287,8 @@
+
+
diff --git a/WOKA/Theme/Controller/BlogsVC.swift b/WOKA/Theme/Controller/BlogsVC.swift
index 865a28b..0e007d1 100644
--- a/WOKA/Theme/Controller/BlogsVC.swift
+++ b/WOKA/Theme/Controller/BlogsVC.swift
@@ -6,13 +6,17 @@
//
import UIKit
+import GoogleMobileAds
class BlogsVC: UIViewController {
@IBOutlet weak var blogCV: UICollectionView!
@IBOutlet weak var noDataStack: UIStackView!
+ @IBOutlet weak var imageAdView: UIImageView!
+ @IBOutlet weak var imageAdHeight: NSLayoutConstraint!
var blogData = [BlogDM.Blog]()
+ var bottomBannerView = GADBannerView()
override func viewDidLoad() {
super.viewDidLoad()
@@ -25,6 +29,43 @@ class BlogsVC: UIViewController {
self.view.applyGradient(colors: [color2, color1], startPoint: CGPoint(x: 0, y: 0), endPoint: CGPoint(x: 0.8, y: 0))
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
+
+ /*
+ First check if webSeries ad is present via slug, then check for Local Ads, if not then check google ads.
+ */
+ if let adsData = AuthFunc.shareInstance.adsData, let blogAd = adsData.result?.filter({$0.slug == AdsEnum.shopListing.rawValue}).first{
+
+ // check if ads data contains LocalAD for webseries
+ if let advertisement = blogAd.advertisement,let bannerImage = advertisement.bannerImage{
+ imageAdView.imageURL(bannerImage, color: .white)
+ imageAdView.alpha = 0
+ let height = UIScreen.main.bounds.width * 0.192
+ imageAdHeight.constant = height
+
+ UIView.animate(withDuration: 0.2, animations: { [weak self] in
+ guard let self else{return}
+ imageAdView.alpha = 1
+ imageAdView.isHidden = false
+ })
+
+ imageAdView.addTapGesture {
+ if let adID = blogAd.id{
+ PersistentStorage.shared.addAdsCount(adID: adID ,clicks: 1)
+ }
+ if let adLink = blogAd.advertisement?.adLink ,let url = URL(string: adLink), UIApplication.shared.canOpenURL(url) {
+ UIApplication.shared.open(url)
+ }
+ }
+ }else if blogAd.googleAd != nil{
+ /*
+ Show google ads with dispatch queue.
+ */
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.2, execute: { [weak self] in
+ guard let self else{return}
+ AdReusable.sharedInstance.setupBannerAd(bannerView: bottomBannerView, in: imageAdView, adUnitID: K.GoogleAdIDs.blogs, viewController: self)
+ })
+ }
+ }
}
override func viewWillAppear(_ animated: Bool) {
@@ -139,3 +180,39 @@ extension BlogsVC : UICollectionViewDelegateFlowLayout{
return CGSize(width: widthPerItem, height: widthPerItem)
}
}
+
+// MARK: - Google Ad Banner Delegate
+
+extension BlogsVC : GADBannerViewDelegate{
+ func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
+ bannerView.alpha = 0
+ bannerView.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
+ UIView.animate(withDuration: 0.3, animations: { [weak self] in
+ guard let self else{return}
+ bannerView.alpha = 1
+ imageAdView.isHidden = false
+ })
+ print("bannerViewDidReceiveAd")
+ }
+
+ func bannerView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: Error) {
+ imageAdView.isHidden = true
+ print("bannerView:didFailToReceiveAdWithError: \(error.localizedDescription)")
+ }
+
+ func bannerViewDidRecordImpression(_ bannerView: GADBannerView) {
+ print("bannerViewDidRecordImpression")
+ }
+
+ func bannerViewWillPresentScreen(_ bannerView: GADBannerView) {
+ print("bannerViewWillPresentScreen")
+ }
+
+ func bannerViewWillDismissScreen(_ bannerView: GADBannerView) {
+ print("bannerViewWillDIsmissScreen")
+ }
+
+ func bannerViewDidDismissScreen(_ bannerView: GADBannerView) {
+ print("bannerViewDidDismissScreen")
+ }
+}
diff --git a/WOKA/Theme/Controller/MoreVC.swift b/WOKA/Theme/Controller/MoreVC.swift
index cb19394..fdfcbda 100644
--- a/WOKA/Theme/Controller/MoreVC.swift
+++ b/WOKA/Theme/Controller/MoreVC.swift
@@ -24,6 +24,8 @@ class MoreVC: UIViewController {
@IBOutlet weak var songRetry: LocalisedElementsButton!
@IBOutlet weak var trailerTask: UIStackView!
@IBOutlet weak var trailerView: UIView!
+ @IBOutlet weak var customAdImage: UIImageView!
+ @IBOutlet weak var customAdHeight: NSLayoutConstraint!
var vm = MoreVM()
var timeObserverToken: Any?
@@ -243,7 +245,8 @@ extension MoreVC : GADBannerViewDelegate{
func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
bannerView.alpha = 0
bannerView.backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
- UIView.animate(withDuration: 0.3, animations: { [unowned self] in
+ UIView.animate(withDuration: 0.3, animations: { [weak self] in
+ guard let self else{return}
trailerView.alpha = 0
bannerView.alpha = 1
})
diff --git a/WOKA/Theme/Controller/UserNotificationVC.swift b/WOKA/Theme/Controller/UserNotificationVC.swift
index d3400a2..65ae5c2 100644
--- a/WOKA/Theme/Controller/UserNotificationVC.swift
+++ b/WOKA/Theme/Controller/UserNotificationVC.swift
@@ -6,27 +6,25 @@
//
import UIKit
+import GoogleMobileAds
class UserNotificationVC: UIViewController {
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var noDataStack: UIStackView!
+ @IBOutlet weak var adView: UIView!
+ @IBOutlet weak var adViewHeight: NSLayoutConstraint!
-
-
var vm = UserNotificationVM()
override func viewDidLoad() {
super.viewDidLoad()
vm.vc = self
vm.initView()
-
navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
navigationController?.navigationBar.shadowImage = UIImage()
}
-
-
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
navigationController?.setNavigationBarHidden(false, animated: animated)
@@ -99,3 +97,43 @@ extension UserNotificationVC : TableViewSRC{
}
}
}
+
+// MARK: - Google Ad Banner Delegate
+
+extension UserNotificationVC : GADBannerViewDelegate{
+
+ func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
+ adView.isHidden = false
+ bannerView.alpha = 0
+ UIView.animate(withDuration: 0.2, animations: {
+ bannerView.alpha = 1
+ })
+ print("bannerViewDidReceiveAd")
+ }
+
+ func bannerView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: Error) {
+ UIView.animate(withDuration: 0.2, animations: { [weak self] in
+ guard let self else{return}
+ bannerView.alpha = 0
+ self.adView.isHidden = false
+ })
+
+ print("bannerView:didFailToReceiveAdWithError: \(error.localizedDescription)")
+ }
+
+ func bannerViewDidRecordImpression(_ bannerView: GADBannerView) {
+ print("bannerViewDidRecordImpression")
+ }
+
+ func bannerViewWillPresentScreen(_ bannerView: GADBannerView) {
+ print("bannerViewWillPresentScreen")
+ }
+
+ func bannerViewWillDismissScreen(_ bannerView: GADBannerView) {
+ print("bannerViewWillDIsmissScreen")
+ }
+
+ func bannerViewDidDismissScreen(_ bannerView: GADBannerView) {
+ print("bannerViewDidDismissScreen")
+ }
+}
diff --git a/WOKA/Theme/ViewModel/MoreVM.swift b/WOKA/Theme/ViewModel/MoreVM.swift
index 0ab6115..84c99ec 100644
--- a/WOKA/Theme/ViewModel/MoreVM.swift
+++ b/WOKA/Theme/ViewModel/MoreVM.swift
@@ -53,8 +53,42 @@ class MoreVM{
}
}
- if let adsData = AuthFunc.shareInstance.adsData, let moreAd = adsData.result?.filter({$0.slug == AdsEnum.more.rawValue}).first, moreAd.googleAd != nil{
- AdReusable.sharedInstance.setupBannerAd(bannerView: headerBannerView, in: vc.trailerTask, adUnitID: K.GoogleAdIDs.splashBanner2, viewController: self.vc, height: 5, width: 15)
+ /*
+ First check if webSeries ad is present via slug, then check for Local Ads, if not then check google ads.
+ */
+ if let adsData = AuthFunc.shareInstance.adsData, let moreAd = adsData.result?.filter({$0.slug == AdsEnum.more.rawValue}).first{
+
+ // check if ads data contains LocalAD for webseries
+ if let advertisement = moreAd.advertisement,let bannerImage = advertisement.bannerImage{
+ vc.customAdImage.imageURL(bannerImage, color: .white)
+ vc.customAdImage.alpha = 0
+ let height = UIScreen.main.bounds.width * 0.55
+ vc.customAdHeight.constant = height
+ vc.trailerTask.isHidden = true
+ vc.customAdImage.isHidden = false
+
+ UIView.animate(withDuration: 0.2, animations: { [weak self] in
+ guard let self else{return}
+ vc.customAdImage.alpha = 1
+ })
+
+ vc.customAdImage.addTapGesture {
+ if let adID = moreAd.id{
+ PersistentStorage.shared.addAdsCount(adID: adID ,clicks: 1)
+ }
+ if let adLink = moreAd.advertisement?.adLink ,let url = URL(string: adLink), UIApplication.shared.canOpenURL(url) {
+ UIApplication.shared.open(url)
+ }
+ }
+ }else if moreAd.googleAd != nil{
+ /*
+ Show google ads with dispatch queue.
+ */
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.2, execute: { [weak self] in
+ guard let self else{return}
+ AdReusable.sharedInstance.setupBannerAd(bannerView: headerBannerView, in: vc.trailerTask, adUnitID: K.GoogleAdIDs.splashBanner2, viewController: self.vc, height: 5, width: 15)
+ })
+ }
}
}
@@ -292,7 +326,9 @@ extension MoreVM{
let commandCenter = MPRemoteCommandCenter.shared()
// Enable play command
- commandCenter.playCommand.addTarget { [unowned self] event in
+ commandCenter.playCommand.addTarget { [weak self] event in
+ guard let self else{return .commandFailed}
+
if player?.rate == 0.0 {
player?.play()
return .success
@@ -301,7 +337,9 @@ extension MoreVM{
}
// Enable pause command
- commandCenter.pauseCommand.addTarget { [unowned self] event in
+ commandCenter.pauseCommand.addTarget { [weak self] event in
+ guard let self else{return .commandFailed}
+
if player?.rate == 1.0 {
// player?.pause()
if let currentIndexPlayingSong{
diff --git a/WOKA/Theme/ViewModel/ThemeOneVM.swift b/WOKA/Theme/ViewModel/ThemeOneVM.swift
index 3b2279b..35f653d 100644
--- a/WOKA/Theme/ViewModel/ThemeOneVM.swift
+++ b/WOKA/Theme/ViewModel/ThemeOneVM.swift
@@ -51,7 +51,7 @@ class ThemeOneVM{
func initView(){
GoogleInterstistialADSetup.shareInstance.setupGoogleIntersitialAD()
-// requestIDFA()
+ requestIDFA()
AuthFunc.shareInstance.initTimePeriods()
startInitialTimer()
// moveCloudView()
diff --git a/WOKA/Theme/ViewModel/UserNotificationVM.swift b/WOKA/Theme/ViewModel/UserNotificationVM.swift
index e76caad..8b1f312 100644
--- a/WOKA/Theme/ViewModel/UserNotificationVM.swift
+++ b/WOKA/Theme/ViewModel/UserNotificationVM.swift
@@ -7,6 +7,7 @@
import UIKit
import Alamofire
+import GoogleMobileAds
class UserNotificationVM{
@@ -14,7 +15,8 @@ class UserNotificationVM{
var userNotification = [UserNotificationDM]()
let refreshControl = UIRefreshControl()
let feedbackGenerator = UIImpactFeedbackGenerator(style: .light)
-
+ var bottomBanner = GADBannerView()
+
func initView(){
let color1 = #colorLiteral(red: 0.05490196078, green: 0.01176470588, blue: 0.3882352941, alpha: 1)
let color2 = #colorLiteral(red: 0.2041364683, green: 0.156624428, blue: 0.5904380268, alpha: 1)
@@ -29,6 +31,60 @@ class UserNotificationVM{
refreshControl.tintColor = .white
refreshControl.addTarget(self, action: #selector(self.refresh(_:)), for: .valueChanged)
vc.tableView.addSubview(refreshControl)
+
+ /*
+ First check if webSeries ad is present via slug, then check for Local Ads, if not then check google ads.
+ */
+ if let adsData = AuthFunc.shareInstance.adsData, let notificatonAd = adsData.result?.filter({$0.slug == AdsEnum.myList.rawValue}).first{
+
+ // check if ads data contains LocalAD for webseries
+ if let advertisement = notificatonAd.advertisement,let bannerImage = advertisement.bannerImage{
+ let height = UIScreen.main.bounds.width * 0.192
+ vc.adViewHeight.constant = height
+ vc.adView.alpha = 0
+ let imageView = UIImageView()
+
+ // Set the image you want to display
+ imageView.imageURL(bannerImage, color: .white)
+
+ // Enable auto-layout
+ imageView.translatesAutoresizingMaskIntoConstraints = false
+
+ // Add the UIImageView to the view
+ vc.adView.addSubview(imageView)
+
+ // Set UIImageView to match the size of the parent UIView
+ NSLayoutConstraint.activate([
+ imageView.leadingAnchor.constraint(equalTo: vc.adView.leadingAnchor),
+ imageView.trailingAnchor.constraint(equalTo: vc.adView.trailingAnchor),
+ imageView.topAnchor.constraint(equalTo: vc.adView.topAnchor),
+ imageView.bottomAnchor.constraint(equalTo: vc.adView.bottomAnchor)
+ ])
+ imageView.contentMode = .scaleAspectFit
+ UIView.animate(withDuration: 0.2, animations: { [weak self] in
+ guard let self else{return}
+ vc.adView.alpha = 1
+ vc.adView.isHidden = false
+ })
+
+ vc.adView.addTapGesture {
+ if let adID = notificatonAd.id{
+ PersistentStorage.shared.addAdsCount(adID: adID ,clicks: 1)
+ }
+ if let adLink = notificatonAd.advertisement?.adLink ,let url = URL(string: adLink), UIApplication.shared.canOpenURL(url) {
+ UIApplication.shared.open(url)
+ }
+ }
+ }else if notificatonAd.googleAd != nil{
+ /*
+ Show google ads with dispatch queue.
+ */
+ //setup google banner ads.
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: {
+ AdReusable.sharedInstance.setupBannerAd(bannerView: self.bottomBanner, in: self.vc.adView, adUnitID: K.GoogleAdIDs.myListNotifications, viewController: self.vc, height: 6,width: 0)
+ })
+ }
+ }
}
func setupCell(){
diff --git a/WOKA/WOKAFM/Controller/WokaFMVC.swift b/WOKA/WOKAFM/Controller/WokaFMVC.swift
index eb6772f..b6395a4 100644
--- a/WOKA/WOKAFM/Controller/WokaFMVC.swift
+++ b/WOKA/WOKAFM/Controller/WokaFMVC.swift
@@ -19,7 +19,8 @@ class WokaFMVC: UIViewController {
@IBOutlet weak var volMinusBtnn: UIButton!
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
@IBOutlet weak var blackView: UIView!
- @IBOutlet weak var adView: UIView!
+ @IBOutlet weak var imageAdView: UIImageView!
+ @IBOutlet weak var imageAdHeight: NSLayoutConstraint!
var vm = WokaFMVM()
@@ -63,9 +64,7 @@ class WokaFMVC: UIViewController {
}
}
}
- }
-
-
+ }
@objc func appWillEnterForeground(){
vm.stopMPNowPlayin()
@@ -242,15 +241,19 @@ extension UIButton {
extension WokaFMVC : GADBannerViewDelegate{
func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
print("bannerViewDidReceiveAd")
- adView.isHidden = false
+ imageAdView.isHidden = false
bannerView.alpha = 0
- bannerView.backgroundColor = #colorLiteral(red: 0.01960784314, green: 0, blue: 0.2196078431, alpha: 1)
UIView.animate(withDuration: 0.2, animations: {
bannerView.alpha = 1
})
}
func bannerView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: Error) {
+ UIView.animate(withDuration: 0.2, animations: { [weak self] in
+ guard let self else{return}
+ bannerView.alpha = 0
+ imageAdView.isHidden = true
+ })
print("bannerView:didFailToReceiveAdWithError: \(error.localizedDescription)")
}
diff --git a/WOKA/WOKAFM/ViewModel/WokaFMVM.swift b/WOKA/WOKAFM/ViewModel/WokaFMVM.swift
index 69d4bd8..b9d66b6 100644
--- a/WOKA/WOKAFM/ViewModel/WokaFMVM.swift
+++ b/WOKA/WOKAFM/ViewModel/WokaFMVM.swift
@@ -102,7 +102,8 @@ class WokaFMVM{
let commandCenter = MPRemoteCommandCenter.shared()
// Enable play command
- commandCenter.playCommand.addTarget { [unowned self] event in
+ commandCenter.playCommand.addTarget { [weak self] event in
+ guard let self else{return .commandFailed}
if player.rate == 0.0 {
player.play()
return .success
@@ -111,7 +112,8 @@ class WokaFMVM{
}
// Enable pause command
- commandCenter.pauseCommand.addTarget { [unowned self] event in
+ commandCenter.pauseCommand.addTarget { [weak self] event in
+ guard let self else{return .commandFailed}
if player.rate == 1.0 {
player.pause()
return .success
@@ -154,16 +156,41 @@ class WokaFMVM{
func setGoogleAd(){
- if let adsData = AuthFunc.shareInstance.adsData, let fmAd = adsData.result?.filter({$0.slug == AdsEnum.fm.rawValue}).first, fmAd.googleAd != nil{
- /*
- Show google ads with dispatch queue.
- */
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.8, execute: { [weak self] in
- guard let self else{return}
- AdReusable.sharedInstance.setupBannerAd(bannerView: self.bottomBannerView, in: vc.adView, adUnitID: K.GoogleAdIDs.wokaFM, viewController: self.vc)
- })
+ /*
+ First check if webSeries ad is present via slug, then check for Local Ads, if not then check google ads.
+ */
+ if let adsData = AuthFunc.shareInstance.adsData, let fmAd = adsData.result?.filter({$0.slug == AdsEnum.fm.rawValue}).first{
+
+ // check if ads data contains LocalAD for webseries
+ if let advertisement = fmAd.advertisement,let bannerImage = advertisement.bannerImage{
+ vc.imageAdView.imageURL(bannerImage, color: .white)
+ vc.imageAdView.alpha = 0
+ let height = UIScreen.main.bounds.width * 0.192
+ vc.imageAdHeight.constant = height
+ UIView.animate(withDuration: 0.2, animations: { [weak self] in
+ guard let self else{return}
+ vc.imageAdView.alpha = 1
+ vc.imageAdView.isHidden = false
+ })
+
+ vc.imageAdView.addTapGesture {
+ if let adID = fmAd.id{
+ PersistentStorage.shared.addAdsCount(adID: adID ,clicks: 1)
+ }
+ if let adLink = fmAd.advertisement?.adLink ,let url = URL(string: adLink), UIApplication.shared.canOpenURL(url) {
+ UIApplication.shared.open(url)
+ }
+ }
+ }else{
+ /*
+ Show google ads with dispatch queue.
+ */
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: { [weak self] in
+ guard let self else{return}
+ AdReusable.sharedInstance.setupBannerAd(bannerView: self.bottomBannerView, in: vc.imageAdView, adUnitID: K.GoogleAdIDs.wokaFM, viewController: self.vc)
+ })
+ }
}
-
}
// MARK: - Setup AV & Player
diff --git a/WOKA/WOKAFM/WokaFM.storyboard b/WOKA/WOKAFM/WokaFM.storyboard
index c6bd329..d93a9e5 100644
--- a/WOKA/WOKAFM/WokaFM.storyboard
+++ b/WOKA/WOKAFM/WokaFM.storyboard
@@ -153,13 +153,12 @@
-
+
-
-
+
-
+
@@ -188,8 +187,9 @@
-
+
+
diff --git a/WOKA/WebSeries/Controller/WebSeriesVC.swift b/WOKA/WebSeries/Controller/WebSeriesVC.swift
index 29f9cd8..1fa7fb7 100644
--- a/WOKA/WebSeries/Controller/WebSeriesVC.swift
+++ b/WOKA/WebSeries/Controller/WebSeriesVC.swift
@@ -201,7 +201,8 @@ extension WebSeriesVC : TableViewSRC{
if let categoryIds = data.favouriteCategoryIDS?.rawValue {
let components = categoryIds.components(separatedBy: ",")
if isFav == true && (components.first == categoryID.toString() || components.last == categoryID.toString()){
- LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: categoryID, vc: self) { [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.removeFavourite(postID: postID, postType: postType, categoryID: categoryID, vc: self) { [weak self] isDone in
+ guard let self else{return}
if isDone{
vm.showData[index].markAsFavourite = false
vm.showData[index].favouriteCategoryIDS = ValueWrapper.stringValue("")
@@ -229,7 +230,8 @@ extension WebSeriesVC : TableViewSRC{
}
}
}else{
- LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: categoryID, vc: self) { [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.addFavourite(postID: postID, postType: postType, categoryID: categoryID, vc: self) { [weak self] isDone in
+ guard let self else{return}
if isDone{
vm.showData[index].markAsFavourite = true
vm.showData[index].favouriteCategoryIDS = ValueWrapper.stringValue(categoryID.toString())
@@ -263,7 +265,8 @@ extension WebSeriesVC : TableViewSRC{
case .liked:
guard let isLiked = data.isLiked ,let postID = data.id,let postType = data.contentMoreDetails?.first?.postType else{return}
if isLiked{
- LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self) { [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.unlikePost(postID: postID, postType: postType, vc: self) { [weak self] isDone in
+ guard let self else{return}
if isDone{
vm.showData[index].isLiked = false
vm.showData[index].likesCount! -= 1
@@ -283,7 +286,8 @@ extension WebSeriesVC : TableViewSRC{
}
}
}else{
- LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self){ [unowned self] isDone in
+ LikeFavCommonFunc.shareInstance.likePost(postID: postID, postType: postType, vc: self){ [weak self] isDone in
+ guard let self else{return}
if isDone{
vm.showData[index].isLiked = true
vm.showData[index].likesCount! += 1