- Added api for getting live stream and fm url
- modified the data for live stream url in theme 1 and theme 2 with speicifed languages also with titles - modified FM url - worked on coredata crud. made functions for crud with queries - added default avatar images for guest - Finalised the Data Model and tried to save and update the counts in local
This commit is contained in:
@@ -141,7 +141,6 @@
|
||||
52A981D82C1B0E27000E0BEC /* FavouriteCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 52A981D62C1B0E27000E0BEC /* FavouriteCell.xib */; };
|
||||
52AC2D252C295A7900337473 /* TeaserDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52AC2D242C295A7900337473 /* TeaserDM.swift */; };
|
||||
52AC2D272C29791500337473 /* JWPlayerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52AC2D262C29791500337473 /* JWPlayerManager.swift */; };
|
||||
52ACC1222C610C5900791528 /* WOKA.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC1202C610C5900791528 /* WOKA.xcdatamodeld */; };
|
||||
52ACC1252C610CBC00791528 /* UserClicks+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC1232C610CBC00791528 /* UserClicks+CoreDataClass.swift */; };
|
||||
52ACC1262C610CBC00791528 /* UserClicks+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC1242C610CBC00791528 /* UserClicks+CoreDataProperties.swift */; };
|
||||
52ACC12A2C610EC900791528 /* PersistentStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52ACC1292C610EC900791528 /* PersistentStorage.swift */; };
|
||||
@@ -244,6 +243,8 @@
|
||||
9C21F81C2C37E1FA0050BFCC /* KaraokeContinueWatchingDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C21F81B2C37E1FA0050BFCC /* KaraokeContinueWatchingDM.swift */; };
|
||||
9C21F81E2C37E3CA0050BFCC /* AVPlayerVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C21F81D2C37E3CA0050BFCC /* AVPlayerVC.swift */; };
|
||||
9C21F8222C382A580050BFCC /* AVPlayerVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C21F8212C382A580050BFCC /* AVPlayerVM.swift */; };
|
||||
9C23FB772C62085C00F4DC5C /* WOKA.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 9C23FB752C62085C00F4DC5C /* WOKA.xcdatamodeld */; };
|
||||
9C23FB792C62164600F4DC5C /* URLStaticDM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C23FB782C62164600F4DC5C /* URLStaticDM.swift */; };
|
||||
9C27E1602BDB6ECA00EC1DA9 /* UserDefaultsStruct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C27E15F2BDB6ECA00EC1DA9 /* UserDefaultsStruct.swift */; };
|
||||
9C27E1632BDB6F1900EC1DA9 /* AuthFunc.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C27E1622BDB6F1900EC1DA9 /* AuthFunc.swift */; };
|
||||
9C27E1652BDB6FBC00EC1DA9 /* StoryBoardID.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9C27E1642BDB6FBC00EC1DA9 /* StoryBoardID.swift */; };
|
||||
@@ -493,7 +494,6 @@
|
||||
52A981D62C1B0E27000E0BEC /* FavouriteCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FavouriteCell.xib; sourceTree = "<group>"; };
|
||||
52AC2D242C295A7900337473 /* TeaserDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TeaserDM.swift; sourceTree = "<group>"; };
|
||||
52AC2D262C29791500337473 /* JWPlayerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JWPlayerManager.swift; sourceTree = "<group>"; };
|
||||
52ACC1212C610C5900791528 /* WOKA.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = WOKA.xcdatamodel; sourceTree = "<group>"; };
|
||||
52ACC1232C610CBC00791528 /* UserClicks+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserClicks+CoreDataClass.swift"; sourceTree = SOURCE_ROOT; };
|
||||
52ACC1242C610CBC00791528 /* UserClicks+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserClicks+CoreDataProperties.swift"; sourceTree = SOURCE_ROOT; };
|
||||
52ACC1292C610EC900791528 /* PersistentStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PersistentStorage.swift; sourceTree = "<group>"; };
|
||||
@@ -600,6 +600,8 @@
|
||||
9C21F81B2C37E1FA0050BFCC /* KaraokeContinueWatchingDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KaraokeContinueWatchingDM.swift; sourceTree = "<group>"; };
|
||||
9C21F81D2C37E3CA0050BFCC /* AVPlayerVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AVPlayerVC.swift; sourceTree = "<group>"; };
|
||||
9C21F8212C382A580050BFCC /* AVPlayerVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AVPlayerVM.swift; sourceTree = "<group>"; };
|
||||
9C23FB762C62085C00F4DC5C /* WOKA.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = WOKA.xcdatamodel; sourceTree = "<group>"; };
|
||||
9C23FB782C62164600F4DC5C /* URLStaticDM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLStaticDM.swift; sourceTree = "<group>"; };
|
||||
9C27E15F2BDB6ECA00EC1DA9 /* UserDefaultsStruct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsStruct.swift; sourceTree = "<group>"; };
|
||||
9C27E1622BDB6F1900EC1DA9 /* AuthFunc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthFunc.swift; sourceTree = "<group>"; };
|
||||
9C27E1642BDB6FBC00EC1DA9 /* StoryBoardID.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StoryBoardID.swift; sourceTree = "<group>"; };
|
||||
@@ -855,7 +857,7 @@
|
||||
9C535DC82C00C34000DA6DCD /* Theme */,
|
||||
52DAC6462C21761700E2F85B /* WebSeries */,
|
||||
9C834ED92C1C20EC00B29A9C /* WOKA.entitlements */,
|
||||
52ACC1202C610C5900791528 /* WOKA.xcdatamodeld */,
|
||||
9C23FB752C62085C00F4DC5C /* WOKA.xcdatamodeld */,
|
||||
52ACC1292C610EC900791528 /* PersistentStorage.swift */,
|
||||
);
|
||||
path = WOKA;
|
||||
@@ -895,6 +897,7 @@
|
||||
children = (
|
||||
9C27E16A2BDB774D00EC1DA9 /* CarouselData.swift */,
|
||||
529B0DD52C070C0F00CFC54B /* GuestDataDM.swift */,
|
||||
9C23FB782C62164600F4DC5C /* URLStaticDM.swift */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
@@ -2189,6 +2192,7 @@
|
||||
52D2F3D82C24043D009E52FF /* ShimmerEffectView.swift in Sources */,
|
||||
9C27E16F2BDB866500EC1DA9 /* CellIdentifier.swift in Sources */,
|
||||
52BC3BF22C170264002FACA6 /* MoreVM.swift in Sources */,
|
||||
9C23FB772C62085C00F4DC5C /* WOKA.xcdatamodeld in Sources */,
|
||||
9CB3D08F2C37D0D60062869D /* KaraokeListingDM.swift in Sources */,
|
||||
52ACC12A2C610EC900791528 /* PersistentStorage.swift in Sources */,
|
||||
9CBE1B412C0F37B300CA6E61 /* DPDUIView+Extension.swift in Sources */,
|
||||
@@ -2323,9 +2327,9 @@
|
||||
9C27E1722BDB86B600EC1DA9 /* OnBoardCell.swift in Sources */,
|
||||
525861D82C4FD38D00C33C79 /* CartPaymentOptionsCell.swift in Sources */,
|
||||
529B0DD42C06156B00CFC54B /* LoginNavVC.swift in Sources */,
|
||||
9C23FB792C62164600F4DC5C /* URLStaticDM.swift in Sources */,
|
||||
52A981D72C1B0E27000E0BEC /* FavouriteCell.swift in Sources */,
|
||||
52BFB0652C5B5B4F0038D750 /* BlogsVC.swift in Sources */,
|
||||
52ACC1222C610C5900791528 /* WOKA.xcdatamodeld in Sources */,
|
||||
52C8B05F2BDA5AFA003B51D0 /* SplashVM.swift in Sources */,
|
||||
52C1A4E12C05B69F007BAA50 /* UIApplicationSwitchRoot.swift in Sources */,
|
||||
527A2BCC2C577F8A0080DF9B /* AnalyticsEventKeys.swift in Sources */,
|
||||
@@ -2827,14 +2831,14 @@
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
|
||||
/* Begin XCVersionGroup section */
|
||||
52ACC1202C610C5900791528 /* WOKA.xcdatamodeld */ = {
|
||||
9C23FB752C62085C00F4DC5C /* WOKA.xcdatamodeld */ = {
|
||||
isa = XCVersionGroup;
|
||||
children = (
|
||||
52ACC1212C610C5900791528 /* WOKA.xcdatamodel */,
|
||||
9C23FB762C62085C00F4DC5C /* WOKA.xcdatamodel */,
|
||||
);
|
||||
currentVersion = 52ACC1212C610C5900791528 /* WOKA.xcdatamodel */;
|
||||
currentVersion = 9C23FB762C62085C00F4DC5C /* WOKA.xcdatamodel */;
|
||||
name = WOKA.xcdatamodeld;
|
||||
path = /Users/macbookpro/Desktop/WOKA/WOKA/WOKA.xcdatamodeld;
|
||||
path = /Users/bilal/Desktop/woka_native_ios_swift/WOKA/WOKA.xcdatamodeld;
|
||||
sourceTree = "<group>";
|
||||
versionGroupType = wrapper.xcdatamodel;
|
||||
};
|
||||
|
||||
21
WOKA/Assets/Assets.xcassets/Home/DefaultAvatar.imageset/Contents.json
vendored
Normal file
21
WOKA/Assets/Assets.xcassets/Home/DefaultAvatar.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "profile_placeholder.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
||||
BIN
WOKA/Assets/Assets.xcassets/Home/DefaultAvatar.imageset/profile_placeholder.png
vendored
Normal file
BIN
WOKA/Assets/Assets.xcassets/Home/DefaultAvatar.imageset/profile_placeholder.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
@@ -24,6 +24,7 @@ class AuthFunc{
|
||||
var playerLooper: AVPlayerLooper?
|
||||
var userType = UserType.adult
|
||||
var userData : UserDataDM.ResultData?
|
||||
var staticURLs : URLStaticDM?
|
||||
|
||||
var languageSelected = LocalizedEnum.english {
|
||||
didSet {
|
||||
@@ -159,6 +160,29 @@ class AuthFunc{
|
||||
UserDefaults.standard.set(data.userType?.toInt(), forKey: K.UserDefaultsStruct.userType)
|
||||
UIApplication.setRootView(SideMenuController.instantiate(from: .Home))
|
||||
}
|
||||
|
||||
// MARK: - Get the Static URL's
|
||||
|
||||
func getStaticURLs(){
|
||||
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.StaticURLs.live_streaming, method: .get, queue : QueueHelper.background) { [weak self](result : Result<BaseResponseModel<URLStaticDM>, NetworkManager.APIError>) in
|
||||
switch result{
|
||||
case .success(let data):
|
||||
guard let self else{return}
|
||||
switch data.success{
|
||||
case 0:
|
||||
break
|
||||
case 1:
|
||||
guard let data = data.data else{return}
|
||||
AuthFunc.shareInstance.staticURLs = data
|
||||
default:
|
||||
break
|
||||
}
|
||||
case .failure(let error):
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Language Enum
|
||||
|
||||
@@ -28,6 +28,7 @@ struct APIEndPoints {
|
||||
struct StaticURLs{
|
||||
// var masilaUrl = "https://content.jwplatform.com/videos/Iygt11AD-Ysj2G4DQ.mp4"
|
||||
static let masilaUrl = "https://cdn.jwplayer.com/manifests/Iygt11AD.m3u8"
|
||||
static let live_streaming = makeURL(path: "live_streaming")
|
||||
}
|
||||
|
||||
struct Auth {
|
||||
|
||||
@@ -78,6 +78,11 @@ class SplashVC: UIViewController {
|
||||
if AuthFunc.shareInstance.checkLogin(){
|
||||
vm.getUserData()
|
||||
return
|
||||
} else{
|
||||
//check if the static url data is fetched
|
||||
if AuthFunc.shareInstance.staticURLs == nil{
|
||||
AuthFunc.shareInstance.getStaticURLs()
|
||||
}
|
||||
}
|
||||
UIView.animate(withDuration: 0.5, animations: {
|
||||
// Update the constant value of the top constraint
|
||||
|
||||
66
WOKA/OnBoarding Module/Model/URLStaticDM.swift
Normal file
66
WOKA/OnBoarding Module/Model/URLStaticDM.swift
Normal file
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// URLStaticDM.swift
|
||||
// WOKA
|
||||
//
|
||||
// Created by Bilal on 06/08/2024.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
// MARK: - URLStaticDM
|
||||
struct URLStaticDM: Codable {
|
||||
let liveFmData: LiveFmData?
|
||||
let liveData: [LiveDatum]?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case liveFmData = "live_fm_data"
|
||||
case liveData = "live_data"
|
||||
}
|
||||
|
||||
// MARK: - LiveDatum
|
||||
struct LiveDatum: Codable {
|
||||
let id: Int?
|
||||
let name: Name?
|
||||
let liveURL: LiveURL?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id, name
|
||||
case liveURL = "live_url"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - LiveURL
|
||||
struct LiveURL: Codable {
|
||||
let hdURLEn, hdURLHin, sdURLEn, sdURLHin: String?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case hdURLEn = "hd_url_en"
|
||||
case hdURLHin = "hd_url_hin"
|
||||
case sdURLEn = "sd_url_en"
|
||||
case sdURLHin = "sd_url_hin"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Name
|
||||
struct Name: Codable {
|
||||
let titleEn, titleHin: String?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case titleEn = "title_en"
|
||||
case titleHin = "title_hin"
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - LiveFmData
|
||||
struct LiveFmData: Codable {
|
||||
let id: Int?
|
||||
let title: String?
|
||||
let liveFmURL: String?
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case id, title
|
||||
case liveFmURL = "live_fm_url"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,7 +18,7 @@ class SplashVM{
|
||||
func initView(){
|
||||
|
||||
// Analytics.logEvent(K.AnalyticsEventKeys.guest_login_iOS, parameters: nil)
|
||||
|
||||
AuthFunc.shareInstance.getStaticURLs()
|
||||
vc.activityIndicator.hidesWhenStopped = true
|
||||
let color1 = #colorLiteral(red: 0.144693464, green: 0.1426281333, blue: 0.6686832905, alpha: 1)
|
||||
let color2 = #colorLiteral(red: 0.4862745098, green: 0.1960784314, blue: 0.7019607843, alpha: 1)
|
||||
@@ -33,9 +33,7 @@ class SplashVM{
|
||||
AuthFunc.shareInstance.languageSelected = language
|
||||
}else{
|
||||
AuthFunc.shareInstance.setDefaultLanguage(language: .english)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -95,6 +93,12 @@ class SplashVM{
|
||||
startStopIndicator(start: false,hide: true)
|
||||
guard let data = data.data?.result else{return}
|
||||
AuthFunc.shareInstance.userData = data
|
||||
|
||||
//check if the static url data is fetched
|
||||
if AuthFunc.shareInstance.staticURLs == nil{
|
||||
AuthFunc.shareInstance.getStaticURLs()
|
||||
}
|
||||
|
||||
UIApplication.setRootView(SideMenuController.instantiate(from: .Home))
|
||||
print("User Token --> ", AuthFunc.shareInstance.getAccessToken())
|
||||
default:
|
||||
@@ -108,6 +112,7 @@ class SplashVM{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// handling activity indicator
|
||||
func startStopIndicator(start : Bool , hide : Bool = false){
|
||||
if hide{
|
||||
|
||||
@@ -13,6 +13,41 @@ import CoreData
|
||||
|
||||
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
|
||||
case category_id
|
||||
case post_id
|
||||
case post_type
|
||||
}
|
||||
|
||||
enum PostType: String {
|
||||
case series = "1"
|
||||
case season = "2"
|
||||
case episode = "3"
|
||||
case video = "4"
|
||||
// case paint = "5"
|
||||
case game = "6"
|
||||
case audio = "7"
|
||||
case karaokeVideo = "8"
|
||||
case shopProduct = "9"
|
||||
// case parentalVideo = "10"
|
||||
// case article = "11"
|
||||
case liveTV = "12"
|
||||
case FM = "13"
|
||||
case teaser = "14"
|
||||
case others = "15"
|
||||
case home = "16"
|
||||
}
|
||||
|
||||
struct UserClickData {
|
||||
let clickCounts: Int
|
||||
let categoryId: Int
|
||||
let postId: Int
|
||||
let postType: Int
|
||||
}
|
||||
|
||||
final class PersistentStorage
|
||||
{
|
||||
|
||||
@@ -47,27 +82,174 @@ final class PersistentStorage
|
||||
}
|
||||
}
|
||||
|
||||
func saveClicksCount(){
|
||||
let clicks = UserClicks(context: PersistentStorage.shared.context)
|
||||
clicks.post_type = 1
|
||||
clicks.post_id = 22
|
||||
clicks.category_id = 33
|
||||
clicks.click_counts = 100
|
||||
PersistentStorage.shared.saveContext()
|
||||
func createData(data : UserClickData){
|
||||
|
||||
//We need to create a context from this container
|
||||
let managedContext = PersistentStorage.shared.context
|
||||
|
||||
let share = UserClicks(context: managedContext)
|
||||
share.click_counts = Int64(data.clickCounts)
|
||||
share.category_id = Int64(data.categoryId)
|
||||
share.post_id = Int64(data.postId)
|
||||
share.post_type = Int64(data.postType)
|
||||
|
||||
do {
|
||||
try managedContext.save()
|
||||
retrieveData()
|
||||
} catch let error as NSError {
|
||||
print("Could not save. \(error), \(error.userInfo)")
|
||||
}
|
||||
}
|
||||
|
||||
func getchClicksCount(){
|
||||
func checkIfExist( key : PersistentStorageEnum , clicksData : UserClickData) {
|
||||
|
||||
let managedContext = PersistentStorage.shared.context
|
||||
let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: PersistentStorageEnum.UserClicks.rawValue)
|
||||
// fetchRequest.fetchLimit = 1
|
||||
// fetchRequest.predicate = NSPredicate(format: "id == %d" ,id)
|
||||
fetchRequest.predicate = NSPredicate(format: "\(key.rawValue) == %@" ,clicksData.postType.toString())
|
||||
|
||||
do {
|
||||
guard let result = try managedContext.fetch(fetchRequest) as? [UserClicks] else {return}
|
||||
if result.isEmpty{
|
||||
//create
|
||||
PersistentStorage.shared.createData(data: clicksData)
|
||||
print("create")
|
||||
}else{
|
||||
//update
|
||||
let objectUpdate = result[0] as NSManagedObject
|
||||
print("Update")
|
||||
objectUpdate.setValue(result.first!.click_counts + Int64(clicksData.clickCounts), forKey: "click_counts")
|
||||
do{
|
||||
try managedContext.save()
|
||||
self.retrieveData()
|
||||
}
|
||||
catch
|
||||
{
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
result.forEach { clicks in
|
||||
print("Counts" , clicks.click_counts)
|
||||
}
|
||||
}catch let error as NSError {
|
||||
print("Could not fetch. \(error), \(error.userInfo)")
|
||||
}
|
||||
}
|
||||
|
||||
func retrieveData() {
|
||||
|
||||
//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])
|
||||
// debugPrint(path[0])
|
||||
|
||||
let fetchRequests = NSFetchRequest<NSFetchRequestResult>(entityName: "UserClicks")
|
||||
|
||||
// fetchRequests.fetchLimit = 1
|
||||
// fetchRequests.predicate = NSPredicate(format: "uuid = %@", "2")
|
||||
// fetchRequests.sortDescriptors = [NSSortDescriptor.init(key: "uuid", ascending: false)]
|
||||
|
||||
do {
|
||||
guard let result = try PersistentStorage.shared.context.fetch(UserClicks.fetchRequest()) as? [UserClicks] else {return}
|
||||
result.forEach({debugPrint("sad", $0.click_counts)})
|
||||
guard let result = try managedContext.fetch(fetchRequests) as? [UserClicks] else {return}
|
||||
result.forEach { clicks in
|
||||
print("ID:-" , clicks.post_type, "Count:-", clicks.click_counts)
|
||||
}
|
||||
|
||||
} catch let error
|
||||
{
|
||||
debugPrint(error)
|
||||
}
|
||||
}
|
||||
|
||||
func updateData(){
|
||||
//We need to create a context from this container
|
||||
let managedContext = PersistentStorage.shared.context
|
||||
|
||||
|
||||
let fetchRequest:NSFetchRequest<NSFetchRequestResult> = NSFetchRequest.init(entityName: "UserClicks")
|
||||
fetchRequest.predicate = NSPredicate(format: "uuid = %@", "2")
|
||||
do
|
||||
{
|
||||
let test = try managedContext.fetch(fetchRequest)
|
||||
|
||||
let objectUpdate = test[0] as! NSManagedObject
|
||||
objectUpdate.setValue("Bilal Ahmed Khan New Name", forKey: "name")
|
||||
do{
|
||||
try managedContext.save()
|
||||
self.retrieveData()
|
||||
}
|
||||
catch
|
||||
{
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
print(error)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func deleteData(){
|
||||
//We need to create a context from this container
|
||||
let managedContext = PersistentStorage.shared.context
|
||||
|
||||
let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "UserClicks")
|
||||
// fetchRequest.fetchLimit = 1
|
||||
// fetchRequest.predicate = NSPredicate(format: "uuid = %@ AND uuid = %@", "1", "1")
|
||||
fetchRequest.predicate = NSPredicate(format: "post_id = %@", "11")
|
||||
|
||||
do
|
||||
{
|
||||
let test = try managedContext.fetch(fetchRequest)
|
||||
|
||||
let objectToDelete = test[0] as! NSManagedObject
|
||||
// test.forEach { obbject in
|
||||
// managedContext.delete(obbject as! NSManagedObject)
|
||||
// }
|
||||
managedContext.delete(test.first as! NSManagedObject)
|
||||
// managedContext.delete(objectToDelete)
|
||||
|
||||
do{
|
||||
try managedContext.save()
|
||||
// self.createData()
|
||||
self.retrieveData()
|
||||
}
|
||||
catch
|
||||
{
|
||||
print(error)
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
print(error)
|
||||
}
|
||||
}
|
||||
|
||||
// func saveClicksCount(){
|
||||
// let clicks = UserClicks(context: PersistentStorage.shared.context)
|
||||
// clicks.post_type = 1
|
||||
// clicks.post_id = 22
|
||||
// clicks.category_id = 33
|
||||
// clicks.click_counts = 100
|
||||
// PersistentStorage.shared.saveContext()
|
||||
// }
|
||||
//
|
||||
// func getchClicksCount(){
|
||||
// let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
|
||||
// debugPrint(path[0])
|
||||
//
|
||||
// do {
|
||||
// guard let result = try PersistentStorage.shared.context.fetch(UserClicks.fetchRequest()) as? [UserClicks] else {return}
|
||||
// result.forEach({debugPrint("sad", $0.click_counts)})
|
||||
//
|
||||
// } catch let error
|
||||
// {
|
||||
// debugPrint(error)
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ class ProductDetailsVC: UIViewController {
|
||||
}
|
||||
|
||||
@IBAction func addToCartBtnTapped(_ sender: LocalisedElementsButton) {
|
||||
if AuthFunc.shareInstance.guestUserLoginPopUp() { return}
|
||||
|
||||
if sender.titleLabel?.text == "Add to Cart"{
|
||||
if let shopMasterID = vm.productDetails?.id{
|
||||
vm.addToCart(shopMasterID: shopMasterID)
|
||||
@@ -72,7 +74,6 @@ class ProductDetailsVC: UIViewController {
|
||||
vm.removeItemFromCart(shopMasterID: shopMasterID)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@IBAction func retryBtnTapped(_ sender: UIButton) {
|
||||
|
||||
@@ -29,6 +29,8 @@ class ProductDetailsVM{
|
||||
}
|
||||
|
||||
@objc func cartButtonTapped(){
|
||||
if AuthFunc.shareInstance.guestUserLoginPopUp() { return}
|
||||
|
||||
let sb = UIStoryboard(name: K.StoryBoard.cart, bundle: nil)
|
||||
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Cart.cartListVC) as! CartListVC
|
||||
self.vc.navigationController?.pushViewController(vcPush, animated: true)
|
||||
|
||||
@@ -26,6 +26,8 @@ class ShopCategoryVM{
|
||||
}
|
||||
|
||||
@objc func cartButtonTapped(){
|
||||
if AuthFunc.shareInstance.guestUserLoginPopUp() { return}
|
||||
|
||||
let sb = UIStoryboard(name: K.StoryBoard.cart, bundle: nil)
|
||||
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Cart.cartListVC) as! CartListVC
|
||||
self.vc.navigationController?.pushViewController(vcPush, animated: true)
|
||||
|
||||
@@ -36,6 +36,8 @@ class ShopListingVM{
|
||||
}
|
||||
|
||||
@objc func cartButtonTapped(){
|
||||
if AuthFunc.shareInstance.guestUserLoginPopUp() { return}
|
||||
|
||||
let sb = UIStoryboard(name: K.StoryBoard.cart, bundle: nil)
|
||||
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Cart.cartListVC) as! CartListVC
|
||||
self.vc.navigationController?.pushViewController(vcPush, animated: true)
|
||||
|
||||
@@ -31,6 +31,8 @@ class ShopProductsVM{
|
||||
}
|
||||
|
||||
@objc func cartButtonTapped(){
|
||||
if AuthFunc.shareInstance.guestUserLoginPopUp() { return}
|
||||
|
||||
let sb = UIStoryboard(name: K.StoryBoard.cart, bundle: nil)
|
||||
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Cart.cartListVC) as! CartListVC
|
||||
self.vc.navigationController?.pushViewController(vcPush, animated: true)
|
||||
|
||||
@@ -33,6 +33,8 @@ class MyOrdersVM{
|
||||
}
|
||||
|
||||
@objc func cartButtonTapped(){
|
||||
if AuthFunc.shareInstance.guestUserLoginPopUp() { return}
|
||||
|
||||
let sb = UIStoryboard(name: K.StoryBoard.cart, bundle: nil)
|
||||
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Cart.cartListVC) as! CartListVC
|
||||
self.vc.navigationController?.pushViewController(vcPush, animated: true)
|
||||
|
||||
@@ -102,6 +102,8 @@ class SideMenuVM{
|
||||
if let avatar = data.avtarURL{
|
||||
// vc.avatarImage.imageURL("https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/storage/app/public/uploads/avtar/avatar2.png?d=1716889852")
|
||||
vc.avatarImage.imageURL(avatar)
|
||||
}else{
|
||||
vc.avatarImage.image = UIImage(named: "DefaultAvatar")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ class ThemeOneVC: UIViewController {
|
||||
|
||||
weak var delegate: ChildViewControllerDelegate?
|
||||
|
||||
|
||||
deinit{
|
||||
timer?.invalidate()
|
||||
// Removing observers
|
||||
@@ -71,6 +70,13 @@ class ThemeOneVC: UIViewController {
|
||||
MyListDataTemp.shareInstance.favListingData = FavouriteListingDM.ResultData(showData: [], videoData: [], gameData: [], singKaraokeData: [], audioData: [])
|
||||
}
|
||||
// connectedToNetwork()
|
||||
|
||||
// PersistentStorage.shared.deleteData()
|
||||
// PersistentStorage.shared.retrieveData()
|
||||
let userClicks = UserClickData(clickCounts: 5, categoryId: 0, postId: 0, postType: 1)
|
||||
PersistentStorage.shared.checkIfExist( key: .post_type,clicksData: userClicks)
|
||||
|
||||
|
||||
}
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
@@ -135,6 +141,9 @@ class ThemeOneVC: UIViewController {
|
||||
vcPush.modalPresentationStyle = .overCurrentContext
|
||||
vcPush.modalTransitionStyle = .crossDissolve
|
||||
self.present(vcPush, animated: true)
|
||||
|
||||
let userClicks = UserClickData(clickCounts: 5, categoryId: 0, postId: 0, postType: 1)
|
||||
PersistentStorage.shared.checkIfExist( key: .post_type,clicksData: userClicks)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class ThemeOneVM{
|
||||
weak var vc : ThemeOneVC!
|
||||
var cloudMovingRight = false // Flag to track the direction of movement
|
||||
var isMovingRight = false // Flag to track the direction of movement
|
||||
var liveStreamURL = "https://d3volyx7jx7oal.cloudfront.net/master.m3u8"
|
||||
// var liveStreamURL = "https://d3volyx7jx7oal.cloudfront.net/master.m3u8"
|
||||
|
||||
var avPlayer : AVPlayer!
|
||||
var playerItem: AVPlayerItem!
|
||||
@@ -113,7 +113,22 @@ class ThemeOneVM{
|
||||
/*
|
||||
Av Player Setup
|
||||
*/
|
||||
guard let streamURL = URL(string: liveStreamURL) else{return}
|
||||
guard let data = AuthFunc.shareInstance.staticURLs , let liveStreamData = data.liveData?.first else{
|
||||
self.vc.toast(msg: "Issue with live streaming", time: 2)
|
||||
return
|
||||
}
|
||||
var url = String()
|
||||
// var title = String()
|
||||
|
||||
if AuthFunc.shareInstance.languageSelected == .english{
|
||||
url = liveStreamData.liveURL?.hdURLEn ?? ""
|
||||
// title = liveStreamData.name?.titleEn ?? ""
|
||||
}else{
|
||||
url = liveStreamData.liveURL?.hdURLHin ?? ""
|
||||
// title = liveStreamData.name?.titleHin ?? ""
|
||||
}
|
||||
|
||||
guard let streamURL = URL(string: url) else{return}
|
||||
|
||||
playerItem = AVPlayerItem(url: streamURL)
|
||||
|
||||
@@ -157,6 +172,8 @@ class ThemeOneVM{
|
||||
if let avatar = data.avtarURL{
|
||||
vc.avatarImage.imageURL(avatar)
|
||||
// vc.avatarImage.imageURL("https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/storage/app/public/uploads/avtar/avatar2.png?d=1716889852")
|
||||
}else{
|
||||
vc.avatarImage.image = UIImage(named: "DefaultAvatar")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,57 +363,75 @@ class ThemeOneVM{
|
||||
Utilities.startProgressHUD(msg: "Loading...")
|
||||
}
|
||||
print("tapped")
|
||||
|
||||
let vc = self.vc.storyboard?.instantiateViewController(withIdentifier: "PlayerVC") as! PlayerVC
|
||||
do {
|
||||
// Ensure the liveStreamURL is valid
|
||||
guard let liveStreamURL = URL(string: self.liveStreamURL) else {
|
||||
print("Invalid live stream URL")
|
||||
Utilities.dismissProgressHUD()
|
||||
return
|
||||
}
|
||||
|
||||
let videoSourceBuilder = try JWVideoSourceBuilder()
|
||||
// .defaultVideo(true)
|
||||
.file(liveStreamURL)
|
||||
.label("Live Stream")
|
||||
.build()
|
||||
|
||||
// Create a JWPlayerItem
|
||||
let item = try JWPlayerItemBuilder()
|
||||
// .file(liveStreamURL)
|
||||
.videoSources([videoSourceBuilder])
|
||||
.build()
|
||||
|
||||
// Create a JWPlayerConfiguration
|
||||
let config = try JWPlayerConfigurationBuilder()
|
||||
.playlist(items: [item])
|
||||
.preload(JWPreload(rawValue: 20) ?? .none)
|
||||
.autostart(true)
|
||||
.build()
|
||||
|
||||
vc.config = config
|
||||
vc.dismissTapped = self.tapped
|
||||
vc.contentType = .liveStream
|
||||
vc.modalPresentationStyle = .fullScreen
|
||||
vc.modalTransitionStyle = .crossDissolve
|
||||
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self else{return}
|
||||
|
||||
// Present the PlayerVC
|
||||
self.vc.present(vc, animated: false) { [weak self] in
|
||||
guard let self else{return}
|
||||
stopLiveStream()
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
print("Error creating JWPlayer configuration: \(error)")
|
||||
|
||||
let vc = self.vc.storyboard?.instantiateViewController(withIdentifier: K.StoryBoardID.Theme.playerVC) as! PlayerVC
|
||||
|
||||
guard let data = AuthFunc.shareInstance.staticURLs , let liveStreamData = data.liveData?.first else{
|
||||
self.vc.toast(msg: "Issue with live streaming", time: 2)
|
||||
return
|
||||
}
|
||||
|
||||
var url = String()
|
||||
var title = String()
|
||||
|
||||
if AuthFunc.shareInstance.languageSelected == .english{
|
||||
url = liveStreamData.liveURL?.hdURLEn ?? ""
|
||||
title = liveStreamData.name?.titleEn ?? ""
|
||||
}else{
|
||||
url = liveStreamData.liveURL?.hdURLHin ?? ""
|
||||
title = liveStreamData.name?.titleHin ?? ""
|
||||
}
|
||||
|
||||
do {
|
||||
// Ensure the liveStreamURL is valid
|
||||
guard let liveStreamURL = URL(string: url) else {
|
||||
print("Invalid live stream URL")
|
||||
Utilities.dismissProgressHUD()
|
||||
return
|
||||
}
|
||||
|
||||
// Dismiss the progress HUD after the view controller presentation
|
||||
let videoSourceBuilder = try JWVideoSourceBuilder()
|
||||
// .defaultVideo(true)
|
||||
.file(liveStreamURL)
|
||||
.label(title)
|
||||
.build()
|
||||
|
||||
// Create a JWPlayerItem
|
||||
let item = try JWPlayerItemBuilder()
|
||||
// .file(liveStreamURL)
|
||||
.videoSources([videoSourceBuilder])
|
||||
.title(title)
|
||||
.build()
|
||||
|
||||
// Create a JWPlayerConfiguration
|
||||
let config = try JWPlayerConfigurationBuilder()
|
||||
.playlist(items: [item])
|
||||
.preload(JWPreload(rawValue: 20) ?? .none)
|
||||
.autostart(true)
|
||||
.build()
|
||||
|
||||
vc.config = config
|
||||
vc.dismissTapped = self.tapped
|
||||
vc.contentType = .liveStream
|
||||
vc.modalPresentationStyle = .fullScreen
|
||||
vc.modalTransitionStyle = .crossDissolve
|
||||
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self else{return}
|
||||
|
||||
// Present the PlayerVC
|
||||
self.vc.present(vc, animated: false) { [weak self] in
|
||||
guard let self else{return}
|
||||
stopLiveStream()
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
print("Error creating JWPlayer configuration: \(error)")
|
||||
Utilities.dismissProgressHUD()
|
||||
}
|
||||
|
||||
// Dismiss the progress HUD after the view controller presentation
|
||||
Utilities.dismissProgressHUD()
|
||||
}
|
||||
|
||||
func tapped(){
|
||||
|
||||
@@ -118,48 +118,73 @@ class ThemeTwoVM{
|
||||
func playLiveTV(){
|
||||
Utilities.startProgressHUD(msg: "Loading...")
|
||||
print("tapped")
|
||||
let vc = self.vc.storyboard?.instantiateViewController(identifier: "PlayerVC") as! PlayerVC
|
||||
let vc = self.vc.storyboard?.instantiateViewController(identifier: K.StoryBoardID.Theme.playerVC) as! PlayerVC
|
||||
|
||||
DispatchQueue.main.async {
|
||||
do {
|
||||
// Create a JWMediaTrack with the thumbnails .vtt file
|
||||
// let thumbnailTrack = try JWThumbnailTrackBuilder()
|
||||
// .file(URL(string:"https://content.jwplatform.com/videos/Agy4RIje-Ysj2G4DQ.mp4")!)
|
||||
// .build()
|
||||
|
||||
// Create a JWPlayerItem
|
||||
let item = try JWPlayerItemBuilder()
|
||||
.file(URL(string: self.liveStreamURL)!)
|
||||
// .posterImage(URL(string: "https://img.freepik.com/free-photo/painting-mountain-lake-with-mountain-background_188544-9126.jpg")!)
|
||||
// .mediaTracks([thumbnailTrack])
|
||||
.build()
|
||||
|
||||
// Create a config, and give it the item as a playlist.
|
||||
let config = try JWPlayerConfigurationBuilder()
|
||||
.playlist(items: [item])
|
||||
.autostart(true)
|
||||
// .preload(.auto)
|
||||
// .repeatContent(true)
|
||||
.build()
|
||||
|
||||
vc.config = config
|
||||
vc.dismissTapped = self.tapped
|
||||
vc.contentType = .liveStream
|
||||
vc.modalPresentationStyle = .overFullScreen
|
||||
vc.modalTransitionStyle = .crossDissolve
|
||||
Utilities.dismissProgressHUD()
|
||||
self.vc.present(vc, animated: false) {
|
||||
self.stopLiveStream()
|
||||
// vc.setDeviceOrientation(orientation: .landscapeRight)
|
||||
}
|
||||
// Utilities.dismissProgressHUD()
|
||||
// self.vc.navigationController?.pushViewController(vc, animated: true)
|
||||
// self.stopLiveStream()
|
||||
}
|
||||
catch {
|
||||
// Handle Error
|
||||
}
|
||||
guard let data = AuthFunc.shareInstance.staticURLs , let liveStreamData = data.liveData?.first else{
|
||||
self.vc.toast(msg: "Issue with live streaming", time: 2)
|
||||
return
|
||||
}
|
||||
var url = String()
|
||||
var title = String()
|
||||
|
||||
if AuthFunc.shareInstance.languageSelected == .english{
|
||||
url = liveStreamData.liveURL?.hdURLEn ?? ""
|
||||
title = liveStreamData.name?.titleEn ?? ""
|
||||
}else{
|
||||
url = liveStreamData.liveURL?.hdURLHin ?? ""
|
||||
title = liveStreamData.name?.titleHin ?? ""
|
||||
}
|
||||
|
||||
do {
|
||||
// Ensure the liveStreamURL is valid
|
||||
guard let liveStreamURL = URL(string: url) else {
|
||||
print("Invalid live stream URL")
|
||||
Utilities.dismissProgressHUD()
|
||||
return
|
||||
}
|
||||
|
||||
let videoSourceBuilder = try JWVideoSourceBuilder()
|
||||
// .defaultVideo(true)
|
||||
.file(liveStreamURL)
|
||||
.label(title)
|
||||
.build()
|
||||
|
||||
// Create a JWPlayerItem
|
||||
let item = try JWPlayerItemBuilder()
|
||||
// .file(liveStreamURL)
|
||||
.videoSources([videoSourceBuilder])
|
||||
.title(title)
|
||||
.build()
|
||||
|
||||
// Create a JWPlayerConfiguration
|
||||
let config = try JWPlayerConfigurationBuilder()
|
||||
.playlist(items: [item])
|
||||
.preload(JWPreload(rawValue: 20) ?? .none)
|
||||
.autostart(true)
|
||||
.build()
|
||||
|
||||
vc.config = config
|
||||
vc.dismissTapped = self.tapped
|
||||
vc.contentType = .liveStream
|
||||
vc.modalPresentationStyle = .fullScreen
|
||||
vc.modalTransitionStyle = .crossDissolve
|
||||
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
guard let self else{return}
|
||||
|
||||
// Present the PlayerVC
|
||||
self.vc.present(vc, animated: false) { [weak self] in
|
||||
guard let self else{return}
|
||||
stopLiveStream()
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
print("Error creating JWPlayer configuration: \(error)")
|
||||
Utilities.dismissProgressHUD()
|
||||
}
|
||||
|
||||
// Dismiss the progress HUD after the view controller presentation
|
||||
Utilities.dismissProgressHUD()
|
||||
}
|
||||
|
||||
func tapped(){
|
||||
@@ -204,6 +229,8 @@ class ThemeTwoVM{
|
||||
if let avatar = data.avtarURL{
|
||||
// vc.avatarImage.imageURL("https://wokaland.com/secret-panel-10102023/hidden-admin-portal-20092023/storage/app/public/uploads/avtar/avatar2.png?d=1716889852")
|
||||
vc.avatarImage.imageURL(avatar)
|
||||
}else{
|
||||
vc.avatarImage.image = UIImage(named: "DefaultAvatar")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +238,19 @@ class ThemeTwoVM{
|
||||
/*
|
||||
Av Player Setup
|
||||
*/
|
||||
guard let streamURL = URL(string: liveStreamURL) else{return}
|
||||
guard let data = AuthFunc.shareInstance.staticURLs , let liveStreamData = data.liveData?.first else{
|
||||
self.vc.toast(msg: "Issue with live streaming", time: 2)
|
||||
return
|
||||
}
|
||||
var url = String()
|
||||
|
||||
if AuthFunc.shareInstance.languageSelected == .english{
|
||||
url = liveStreamData.liveURL?.hdURLEn ?? ""
|
||||
}else{
|
||||
url = liveStreamData.liveURL?.hdURLHin ?? ""
|
||||
}
|
||||
|
||||
guard let streamURL = URL(string: url) else{return}
|
||||
|
||||
playerItem = AVPlayerItem(url: streamURL)
|
||||
|
||||
|
||||
@@ -11,10 +11,7 @@ import AVFoundation
|
||||
class WokaFMVM{
|
||||
|
||||
weak var vc : WokaFMVC!
|
||||
|
||||
//Approved url from client
|
||||
var url = "https://stream.rcast.net/71643"
|
||||
|
||||
|
||||
var player: AVPlayer!
|
||||
var playerItem: AVPlayerItem!
|
||||
|
||||
@@ -44,7 +41,12 @@ class WokaFMVM{
|
||||
}
|
||||
|
||||
func setupPlayer() {
|
||||
guard let url = URL(string: url) else{return}
|
||||
guard let data = AuthFunc.shareInstance.staticURLs , let liveFmURL = data.liveFmData?.liveFmURL else{
|
||||
self.vc.toast(msg: "Issue with Radio", time: 2)
|
||||
return
|
||||
}
|
||||
|
||||
guard let url = URL(string: liveFmURL) else{return}
|
||||
playerItem = AVPlayerItem(url: url)
|
||||
player = AVPlayer(playerItem: playerItem)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user