- Fixed a bug for logout, clearing cache for my list

- Made last data sync, will check in 1 hour if the last sync done time is past 1 hour, will give a sync in background
- 3-3:30 meeting with WOKA for ads
- Finalised the data sync when app goes in background.
- Muted google ads from splash.
- Completed Data sync from logout , it will now show first its syncing the data and then it will logout.
This commit is contained in:
2024-09-24 20:10:45 +05:30
parent bf189c118d
commit 129be7142a
19 changed files with 242 additions and 100 deletions

View File

@@ -853,6 +853,15 @@
path = Validations;
sourceTree = "<group>";
};
521E5A9E2CA2AD3500AEF131 /* DataSync&AdsManage */ = {
isa = PBXGroup;
children = (
52ACC1292C610EC900791528 /* PersistentStorage.swift */,
52CC4A732C883B3F001BE47C /* AdsDM.swift */,
);
path = "DataSync&AdsManage";
sourceTree = "<group>";
};
522242582BFC73E40085C632 /* SideMenu */ = {
isa = PBXGroup;
children = (
@@ -947,6 +956,7 @@
523ED25C2BDA2BC700CFED02 /* WOKA */ = {
isa = PBXGroup;
children = (
521E5A9E2CA2AD3500AEF131 /* DataSync&AdsManage */,
5276865D2C8879FD001A5496 /* AdClicksImpressions+CoreDataClass.swift */,
5276865E2C8879FD001A5496 /* AdClicksImpressions+CoreDataProperties.swift */,
527A2BD32C57D0B20080DF9B /* Address */,
@@ -972,7 +982,6 @@
9C27E1612BDB6F0F00EC1DA9 /* Main */,
525954152BE8CAC900191286 /* Network Adapter */,
523ED28E2BDA372C00CFED02 /* OnBoarding Module */,
52ACC1292C610EC900791528 /* PersistentStorage.swift */,
52A6DC942C4E385500F63C51 /* Shop */,
522A93142C0DE8770098FE49 /* SideBarNav */,
525327D72BFCC30400F64283 /* TabBar & SideMenu */,
@@ -1721,7 +1730,6 @@
525327D82BFCDDF700F64283 /* AuthFuncStartupSoundHandling.swift */,
52FDBA7A2BFF2712009D7AC7 /* AuthFuncTimeHandling.swift */,
9CC0D2F92C6F33BE0019DF73 /* AuthFuncUserVideoView.swift */,
52CC4A732C883B3F001BE47C /* AdsDM.swift */,
);
path = AuthFunc;
sourceTree = "<group>";

View File

@@ -99,7 +99,7 @@ class AudioBookHomeVC: UIViewController {
*/
if let adsData = AuthFunc.shareInstance.adsData{
// check if ads data contains ad for webseries
if let audioBooksAd = adsData.result?.filter({$0.slug == AdsEnum.audioBooks.rawValue}).first, let adLink = audioBooksAd.advertisement?.adLink, let adID = audioBooksAd.id{
if let audioBooksAd = adsData.result?.filter({$0.slug == AdsEnum.audioBooks.rawValue}).first, let adLink = audioBooksAd.advertisement?.adLink, let adID = audioBooksAd.advertisement?.id{
PersistentStorage.shared.addAdsCount(adID: adID,clicks: 1)
if let url = URL(string: adLink), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)

View File

@@ -41,10 +41,40 @@ extension K{
*/
static var adTimeStamp : Date? = nil
/*
This will handle sync timing for sending data from coredata.
Basically keeping this to do the sync every hour if data is founnd
*/
static var lastDataSync : Date? = nil
/*
User Skipped update
*/
static var skippedUpdate : Bool? = nil
/*
Reset to defaults at the time of logout
*/
static func resetToDefault() {
lastOpenTimestamp = nil
reloadMyList = false
topView = TopViewEnum.theme1
myListSoftReload = false
reloadMyListAudioBooks = false
reloadKaraoke = false
reloadGames = false
reloadHindiWebseries = false
reloadEnglishWebseries = false
reloadMyListAll = 0
reloadMyListAllID = 0
reloadContinueKaraoke = false
reloadContinueAudioBooks = false
reloadContinueWebSeries = false
selectedUsername = nil
adTimeStamp = nil
lastDataSync = nil
skippedUpdate = nil
}
}
}

View File

@@ -8,11 +8,6 @@
import Foundation
import CoreData
/**
Hey there, I hope you enjoyed the video, if you have any questions then please feel free to ask I will be happy to answer them.
Do share this with your iOS group on whatsapp or facebook or anyone who wants to learn iOS
*/
enum PersistentStorageEnum : String{
case UserClicks
case click_counts
@@ -72,13 +67,6 @@ struct AdsClickImpressionsData : Codable {
}
}
//struct UserVideoViewData {
// let postId: Int
// let postType: Int
// let watchedDuration: Double
// let categoryId: Int
//}
final class PersistentStorage
{
@@ -225,13 +213,10 @@ final class PersistentStorage
}
//Sending Clicks data to our server
func sendDataToServer() {
func sendDataToServer(isLogout : Bool = false) {
//We need to create a context from this container
let managedContext = PersistentStorage.shared.context
// let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
// debugPrint(path[0])
let fetchRequest:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "UserClicks")
fetchRequest.fetchLimit = 15
do {
@@ -241,8 +226,8 @@ final class PersistentStorage
print("UserClicks Count from SendData to server :- ", result.count)
//if data is less , dont keep sending the data to server
if result.count < 5 {
print("Not Enough Data")
if isLogout == false,result.count < 3 {
print("Not Enough Clicks Data")
return
}
@@ -256,7 +241,7 @@ final class PersistentStorage
// send data to server
NetworkManager.shareInstance.nwCallRawJSON(clicksData: userClicks) { isDone in
if isDone{ // if data is send to server and we get success callback then delete that data from coredata entity.
self.deleteData(result)
self.deleteData(result,isLogout: isLogout)
}
}
}
@@ -267,7 +252,7 @@ final class PersistentStorage
}
//Delete data from CoreData
func deleteData(_ data: [UserClicks]) {
func deleteData(_ data: [UserClicks],isLogout : Bool = false) {
let managedContext = PersistentStorage.shared.context
data.forEach { clicks in
@@ -278,7 +263,7 @@ final class PersistentStorage
try managedContext.save()
//after deleting check if more data exist.
getAllData()
getAllData(isLogout: isLogout)
print("Deleted data")
} catch let error {
debugPrint("Failed to delete data:", error)
@@ -286,7 +271,7 @@ final class PersistentStorage
}
//Get all data from DB
func getAllData() {
func getAllData(isLogout : Bool = false) {
//We need to create a context from this container
let managedContext = PersistentStorage.shared.context
let fetchRequest:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "UserClicks")
@@ -296,7 +281,7 @@ final class PersistentStorage
print("UserClicks Count from getAllData :- ", result.count)
//if data is less , dont keep sending the data to server
if result.count < 5 {
if isLogout == false,result.count < 5 {
print("Not Enough Data")
return
} else{
@@ -364,9 +349,13 @@ final class PersistentStorage
let userClicks = UserClickData(clickCounts: 1, categoryId: catID, postId: postID, postType: postType.rawValue)
PersistentStorage.shared.checkWebSeries(clicksData: userClicks)
}
// MARK: - Handling ADS
}
func sendAdsData() {
// MARK: - Handling ADS
extension PersistentStorage{
func sendAdsData(isLogout : Bool = false) {
//create a context from this container
let managedContext = PersistentStorage.shared.context
@@ -378,20 +367,21 @@ final class PersistentStorage
print("userImpressions Count from SendAdsData to server :- ", result.count)
//if data is less , dont keep sending the data to server
if result.count < 2 {
print("Not Enough Data")
if isLogout == false,result.count < 2 {
print("Not Enough Ads Data")
return
}
var userImpressions = [AdsClickImpressionsData]()
//map the impressions
result.forEach { ads in
// device type 1- android , 2 - iOS
userImpressions.append(AdsClickImpressionsData(adID: Int(ads.ad_id), noOfClick: Int(ads.no_of_click), noOfOmpression: Int(ads.no_of_impression)))
print("ID:-" , ads.ad_id, "No Of Clicks :- ", ads.no_of_click, "Impressions :- ", ads.no_of_impression)
print("ADs Data :- ","ID:-" , ads.ad_id, "No Of Clicks :- ", ads.no_of_click, "Impressions :- ", ads.no_of_impression)
}
//Send it to server and delete from our DB
NetworkManager.shareInstance.nwCallRawJSONAds(adsData: userImpressions) { isDone in
if isDone{
self.deleteAdsData(result)
@@ -404,8 +394,50 @@ final class PersistentStorage
}
}
func checkIfAdExist(adsData : AdsClickImpressionsData) {
func deleteAdsData(_ data: [AdClicksImpressions],isLogout : Bool = false) {
let managedContext = PersistentStorage.shared.context
data.forEach { clicks in
managedContext.delete(clicks)
}
do {
try managedContext.save()
getAllAdsData(isLogout: isLogout)
print("Deleted data")
} catch let error {
debugPrint("Failed to delete data:", error)
}
}
func getAllAdsData(isLogout : Bool = false) {
//We need to create a context from this container
let managedContext = PersistentStorage.shared.context
let fetchRequest:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "AdClicksImpressions")
do {
guard let result = try managedContext.fetch(fetchRequest) as? [AdClicksImpressions] else {return}
print("UserClicks Count from getAllData :- ", result.count)
//if data is less , dont keep sending the data to server
if isLogout == false,result.count < 2 {
print("Not Enough Ads Data")
return
}else{
// send ads data again to server
sendAdsData()
print("Ads Data sent Again.")
}
// result.forEach { clicks in
// // device type 1- android , 2 - iOS
// print("ID:-" , PostType(rawValue: Int(clicks.post_type))!, "CatID:- ", clicks.category_id, "PostID:- ", clicks.post_id , "Count:-", clicks.click_counts)
// }
} catch let error{
debugPrint(error)
}
}
func checkIfAdExist(adsData : AdsClickImpressionsData) {
let managedContext = PersistentStorage.shared.context
let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: "AdClicksImpressions")
fetchRequest.predicate = NSPredicate(format: "ad_id == %@" ,adsData.adID.toString())
@@ -436,8 +468,9 @@ final class PersistentStorage
}
}
func createAdsData(data : AdsClickImpressionsData){
// MARK: - Add Ads to CoreData
func createAdsData(data : AdsClickImpressionsData){
//We need to create a context from this container
let managedContext = PersistentStorage.shared.context
@@ -448,6 +481,7 @@ final class PersistentStorage
do {
try managedContext.save()
//show the ad saved in cored data
retrieveAdsData(adID: data.adID)
} catch let error as NSError {
print("Could not save. \(error), \(error.userInfo)")
@@ -476,49 +510,59 @@ final class PersistentStorage
PersistentStorage.shared.checkIfAdExist( adsData: adsData)
}
func deleteAdsData(_ data: [AdClicksImpressions]) {
let managedContext = PersistentStorage.shared.context
}
data.forEach { clicks in
managedContext.delete(clicks)
}
// MARK: - Sync CoreData to server
extension PersistentStorage{
func getEntityDataCount() -> (Int,Int){
let managedContext = PersistentStorage.shared.context
let adsFetchReq:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "AdClicksImpressions")
let clicksFetchReq:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "UserClicks")
do {
try managedContext.save()
getAllAdsData()
print("Deleted data")
} catch let error {
debugPrint("Failed to delete data:", error)
// Perform the count request
let adsCount = try managedContext.count(for: adsFetchReq)
let clicksCount = try managedContext.count(for: clicksFetchReq)
return (adsCount,clicksCount)
} catch let error as NSError {
print("Error fetching count: \(error), \(error.userInfo)")
return (0,0)
}
}
func getAllAdsData() {
//We need to create a context from this container
let managedContext = PersistentStorage.shared.context
let fetchRequest:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "AdClicksImpressions")
// fetchRequest.fetchLimit = 2
do {
guard let result = try managedContext.fetch(fetchRequest) as? [AdClicksImpressions] else {return}
func checkLastSync(){
/*
check ad timestamp from gvar
show ads if the saved timestamp time and current time has diffrenece of 30 minutes
*/
if let timeStamp = K.GVar.lastDataSync{
/*
check if timestamp difference is equal and greater than 60 minutes i.e 3600 seconds
*/
let duration = DateFormatterLib.dateDifferenceINT(date1: timeStamp, date2: Date())
print("Last Sync Duration :- ", duration, " Seconds.")
print("UserClicks Count from getAllData :- ", result.count)
//if data is less , dont keep sending the data to server
if result.count < 2 {
print("Not Enough Ads Data")
return
} else{
// send ads data again to server
sendAdsData()
print("Ads Data sent Again.")
if duration <= 3600{ //if last data sync has not
// dont sync data.
print("Last sync has not passed 1 hour")
}else{
//Sync data to server if the last sync time has been changed.
syncData()
}
}else{
/*
Assign the date and sync the data to server
*/
syncData()
}
}
// result.forEach { clicks in
// // device type 1- android , 2 - iOS
// print("ID:-" , PostType(rawValue: Int(clicks.post_type))!, "CatID:- ", clicks.category_id, "PostID:- ", clicks.post_id , "Count:-", clicks.click_counts)
// }
}
catch let error
{
debugPrint(error)
}
func syncData(){
K.GVar.lastDataSync = Date()
self.sendAdsData()
self.sendDataToServer()
print("Data Synced to Server.")
}
}

View File

@@ -67,7 +67,7 @@ class GamesListVC: UIViewController {
*/
if let adsData = AuthFunc.shareInstance.adsData{
// check if ads data contains ad for webseries
if let gamesAd = adsData.result?.filter({$0.slug == AdsEnum.games.rawValue}).first, let adID = gamesAd.id{
if let gamesAd = adsData.result?.filter({$0.slug == AdsEnum.games.rawValue}).first, let adID = gamesAd.advertisement?.id{
PersistentStorage.shared.addAdsCount(adID: adID ,impressions: 1)
}
}
@@ -86,7 +86,7 @@ class GamesListVC: UIViewController {
*/
if let adsData = AuthFunc.shareInstance.adsData{
// check if ads data contains ad for webseries
if let gamesAd = adsData.result?.filter({$0.slug == AdsEnum.games.rawValue}).first, let adLink = gamesAd.advertisement?.adLink, let adID = gamesAd.id{
if let gamesAd = adsData.result?.filter({$0.slug == AdsEnum.games.rawValue}).first, let adLink = gamesAd.advertisement?.adLink, let adID = gamesAd.advertisement?.id{
PersistentStorage.shared.addAdsCount(adID: adID,clicks: 1)
if let url = URL(string: adLink), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)

View File

@@ -18,13 +18,7 @@ class HomeVC: UIViewController ,ChildViewControllerDelegate{
override func viewDidLoad() {
super.viewDidLoad()
//setup google ads for fullscreen if its turned on.
if let adsData = AuthFunc.shareInstance.adsData, let gamesIntersitialAd = adsData.result?.filter({$0.slug == AdsEnum.gameInterestial.rawValue}).first, gamesIntersitialAd.googleAd != nil{
/*
setup google ads.
*/
GoogleInterstistialADSetup.shareInstance.setupGoogleIntersitialAD()
}
switch AuthFunc.shareInstance.selectedTheme {
case .theme1:

View File

@@ -18,6 +18,10 @@ class MyListDataTemp{
var isDatafetched = false
func removeAll(){
isDatafetched = false
MyListDataTemp.shareInstance.favListingData = nil
}
// MARK: - Get Favourite Listing

View File

@@ -52,6 +52,8 @@ class MyListVM{
DispatchQueue.main.async {
self.vc.shimmerView.forEach { shimmer in
if load{
shimmer.gradientColorOne = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
shimmer.gradientColorTwo = #colorLiteral(red: 0.6, green: 0.8862745098, blue: 1, alpha: 1)
shimmer.startShimmer()
}else{
shimmer.stopShimmer()

View File

@@ -195,8 +195,18 @@ class AuthFunc{
UserDefaults.standard.setValue(nil, forKey: K.UserDefaultsStruct.isUserLogined)
UserDefaults.standard.setValue(nil, forKey: K.UserDefaultsStruct.userAccessToken)
UserDefaults.standard.setValue(nil, forKey: K.UserDefaultsStruct.userType)
//clear userdata
userData = nil
//clear cart & Mylist cache
CartDataCache.shareInstance.removeAll()
MyListDataTemp.shareInstance.removeAll()
//Reset the Global Var
K.GVar.resetToDefault()
//Reset default selected theme
selectedTheme = .theme1
}
@@ -245,6 +255,13 @@ class AuthFunc{
case 1:
guard let data = data.data else{return}
AuthFunc.shareInstance.adsData = data
//setup google ads for fullscreen if its turned on.
// if let gamesIntersitialAd = data.result?.filter({$0.slug == AdsEnum.gameInterestial.rawValue}).first, gamesIntersitialAd.googleAd != nil{
// /*
// setup google ads.
// */
// GoogleInterstistialADSetup.shareInstance.setupGoogleIntersitialAD()
// }
onCompletion?(true)
default:
onCompletion?(false)

View File

@@ -44,6 +44,13 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// Called as the scene transitions from the foreground to the background.
// Use this method to save data, release shared resources, and store enough scene-specific state information
// to restore the scene back to its current state.
/*
If user is loggined check for sync
*/
if AuthFunc.shareInstance.checkLogin(){
PersistentStorage.shared.checkLastSync()
}
}

View File

@@ -126,7 +126,8 @@ class JWPlayerManager {
let adBreakBuilder1 = JWAdBreakBuilder()
.offset(.midroll(percent: 20))
// .offset(.from(string: "20%")!)
.tags([URL(string: "https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250,728x90&gdfp_req=1&output=vast4&unviewed_position_start=1&env=vp&impl=s&correlator=7898879")!])
// .tags([URL(string: "https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_preroll_skippable&sz=640x480&ciu_szs=300x250,728x90&gdfp_req=1&output=vast4&unviewed_position_start=1&env=vp&impl=s&correlator=7898879")!])
.tags([URL(string: "https://pubads.g.doubleclick.net/gampad/ads?iu=/23204950200/VideoAd&description_url=https%3A%2F%2Fwokaland.com%2F&tfcd=0&npa=0&sz=480x320%7C640x480&ciu_szs=480x320&min_ad_duration=5000&max_ad_duration=20000&gdfp_req=1&unviewed_position_start=1&output=vast&env=vp&impl=s&correlator=")!])
guard let adBreak1 = try? adBreakBuilder1.build() else {
print("Ad error 2")

View File

@@ -35,8 +35,8 @@ class SplashVC: UIViewController {
*/
DispatchQueue.main.asyncAfter(deadline: .now(), execute: { [weak self] in
guard let self else{return}
AdReusable.sharedInstance.setupBannerAd(bannerView: vm.banner1, in: adBanner1, adUnitID: K.GoogleAdIDs.splashBanner1, viewController: self)
AdReusable.sharedInstance.setupBannerAd(bannerView: vm.banner2, in: adBanner2, adUnitID: K.GoogleAdIDs.splashBanner2, viewController: self)
// AdReusable.sharedInstance.setupBannerAd(bannerView: vm.banner1, in: adBanner1, adUnitID: K.GoogleAdIDs.splashBanner1, viewController: self)
// AdReusable.sharedInstance.setupBannerAd(bannerView: vm.banner2, in: adBanner2, adUnitID: K.GoogleAdIDs.splashBanner2, viewController: self)
vm.initView()
})
@@ -54,7 +54,6 @@ class SplashVC: UIViewController {
vm.playSplashSound()
animateImageScale()
}
@IBAction func languageBtnTapped(_ sender: UIButton) {

View File

@@ -55,7 +55,7 @@ class ShopListingVC: UIViewController {
*/
if let adsData = AuthFunc.shareInstance.adsData{
// check if ads data contains ad for webseries
if let shopSuperCatAd = adsData.result?.filter({$0.slug == AdsEnum.shop_super_category.rawValue}).first, let adID = shopSuperCatAd.id{
if let shopSuperCatAd = adsData.result?.filter({$0.slug == AdsEnum.shop_super_category.rawValue}).first, let adID = shopSuperCatAd.advertisement?.id{
PersistentStorage.shared.addAdsCount(adID: adID ,impressions: 1)
}
}
@@ -95,7 +95,7 @@ extension ShopListingVC : TableViewSRC{
if vm.superCatData[indexPath.row].isAD == true{
if let adsData = AuthFunc.shareInstance.adsData{
// check if ads data contains ad for webseries
if let shopSuperCatAd = adsData.result?.filter({$0.slug == AdsEnum.shop_super_category.rawValue}).first,let adLink = shopSuperCatAd.advertisement?.adLink, let adID = shopSuperCatAd.id{
if let shopSuperCatAd = adsData.result?.filter({$0.slug == AdsEnum.shop_super_category.rawValue}).first,let adLink = shopSuperCatAd.advertisement?.adLink, let adID = shopSuperCatAd.advertisement?.id{
PersistentStorage.shared.addAdsCount(adID: adID,clicks: 1)
if let url = URL(string: adLink), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)

View File

@@ -90,7 +90,7 @@ class ShopListingVM{
if let adsData = AuthFunc.shareInstance.adsData{
// check if ads data contains ad for webseries
if let shopSuperCatAd = adsData.result?.filter({$0.slug == AdsEnum.shop_super_category.rawValue}).first, let bannerImage = shopSuperCatAd.advertisement?.bannerImage{
self.superCatData.append(ShopSuperCategoryDM.ResultData(id: shopSuperCatAd.id, superCategoryName: shopSuperCatAd.advertisement?.title, superCategoryThumbnail: bannerImage,isAD: true))
self.superCatData.append(ShopSuperCategoryDM.ResultData(id: shopSuperCatAd.advertisement?.id, superCategoryName: shopSuperCatAd.advertisement?.title, superCategoryThumbnail: bannerImage,isAD: true))
}else{ // check if google ads
}

View File

@@ -114,12 +114,15 @@ class SideMenuVC: UIViewController {
switch mode{
case .yes:
PersistentStorage.shared.addOthersCount()
//If user clicked to proceed on login. Call the api.
vm.logoutUser { isDone in
self.sideMenuController?.hideMenu()
AuthFunc.shareInstance.logout()
UIApplication.setRootView(LoginNavVC.instantiate(from: .AuthenticationSB))
}
/*
Make sure all data is synced to the server for click data & ad impressions
*/
PersistentStorage.shared.sendAdsData(isLogout: true)
PersistentStorage.shared.sendDataToServer(isLogout: true)
Utilities.startProgressHUD(msg: "Syncing...")
vm.checkData()
// self.timer.
case .no:
PersistentStorage.shared.addOthersCount()
print("no")

View File

@@ -11,6 +11,7 @@ import Alamofire
class SideMenuVM{
weak var vc : SideMenuVC!
var syncTimer : Timer?
func initView(){
@@ -178,4 +179,35 @@ class SideMenuVM{
}
}
}
// MARK: - Sync Data
func startSyncTimer(){
if syncTimer == nil {
syncTimer = Timer.scheduledTimer(timeInterval: 2.5, target: self, selector: #selector(checkData), userInfo: nil, repeats: true)
}
}
@objc func checkData(){
let count = PersistentStorage.shared.getEntityDataCount()
if count.0 == 0 && count.1 == 0{ // ads , clicks
// if ads and clicks are synced to server, make sure to stop timer and logout user
stopSyncTimer()
Utilities.dismissProgressHUD()
//If user clicked to proceed on login. Call the api.
logoutUser { isDone in
self.vc.sideMenuController?.hideMenu()
AuthFunc.shareInstance.logout()
UIApplication.setRootView(LoginNavVC.instantiate(from: .AuthenticationSB))
}
}else{
startSyncTimer()
}
}
func stopSyncTimer(){
syncTimer?.invalidate()
syncTimer = nil
}
}

View File

@@ -98,7 +98,7 @@ class ThemeOneVC: UIViewController {
}
override func viewDidAppear(_ animated: Bool) {
AuthFunc.shareInstance.getAds()
// AuthFunc.shareInstance.getAds()
K.GVar.topView = .theme1
vm.shouldAnimate = true
@@ -116,10 +116,11 @@ class ThemeOneVC: UIViewController {
*/
if let adsData = AuthFunc.shareInstance.adsData{
// check if ads data contains ad for webseries
if let themeOneAd = adsData.result?.filter({$0.slug == AdsEnum.themeOne.rawValue}).first, let adID = themeOneAd.id{
if let themeOneAd = adsData.result?.filter({$0.slug == AdsEnum.themeOne.rawValue}).first, let adID = themeOneAd.advertisement?.id{
PersistentStorage.shared.addAdsCount(adID: adID ,impressions: 1)
}
}
}
override func viewDidLayoutSubviews() {

View File

@@ -315,7 +315,7 @@ class ThemeOneVM{
//check url from api
if let adsData = AuthFunc.shareInstance.adsData{
// check if ads data contains ad for webseries
if let themeOneAd = adsData.result?.filter({$0.slug == AdsEnum.themeOne.rawValue}).first, let adLink = themeOneAd.advertisement?.adLink, let adID = themeOneAd.id{
if let themeOneAd = adsData.result?.filter({$0.slug == AdsEnum.themeOne.rawValue}).first, let adLink = themeOneAd.advertisement?.adLink, let adID = themeOneAd.advertisement?.id{
PersistentStorage.shared.addAdsCount(adID: adID,clicks: 1)
if let url = URL(string: adLink), UIApplication.shared.canOpenURL(url) {