- handled theme 2 player pause while the radio is opened and closed

- Completed forget username flow with hindi language
- Completed app update functionality, need the api to be updated as the version will not be a double, its going to be string
This commit is contained in:
2024-08-20 19:50:11 +05:30
parent 9b9e95301e
commit 750cc59cde
23 changed files with 903 additions and 98 deletions

View File

@@ -16,7 +16,9 @@ class SplashVM{
var player: AVAudioPlayer?
func initView(){
AuthFunc.shareInstance.getStaticURLs()
if AuthFunc.shareInstance.staticURLs == 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)
@@ -111,6 +113,72 @@ class SplashVM{
}
}
func getVersionHistory(){
let newVersion = "25.1.7"
let forceUpdateVersion = "25.1.7"
let forceUpdate = false
let currentAppVersion = Bundle.main.appVersionLong
/*
If user is guest then dont do the nw call
*/
let params : Parameters = ["device" : "2"] //1-android , 2- iOS
NetworkManager.shareInstance.apiRequest(url: APIEndPoints.Auth.version_history, method: .get,parameters: params) { [weak self](result : Result<BaseResponseModel<AppUpdateDM>, NetworkManager.APIError>) in
switch result{
case .success(let data):
guard let self else{return}
switch data.success{
case 0:
self.vc.toast(msg: data.message ?? "Unrecognised error" , time: 2)
case 1:
guard let data = data.data?.the0 else{return}
if newVersion.isVersion(greaterThan: currentAppVersion) {
// Case: New version is greater than the current version
print("New version is greater than current version.")
/*
Check if user has skipped the force update version
*/
let skippedVer = UserDefaults.standard.string(forKey: K.UserDefaultsStruct.appUpdateSkipVer)
if skippedVer == forceUpdateVersion{
// it means user has skipped this version.
vc.animateForward()
return
}
// If ver is not skipped let user navigate to app update vc
if forceUpdate {
print("Force update required by the API.")
// nav user to force update screen
let sb = UIStoryboard(name: K.StoryBoard.authenticationSB, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Authentication.appUpdateVC) as! AppUpdateVC
vcPush.forceUpdateVer = forceUpdateVersion
self.vc.navigationController?.pushViewController(vcPush, animated: true)
} else {
print("Update available, but not mandatory.")
// Optional update let user skip
let sb = UIStoryboard(name: K.StoryBoard.authenticationSB, bundle: nil)
let vcPush = sb.instantiateViewController(withIdentifier: K.StoryBoardID.Authentication.appUpdateVC) as! AppUpdateVC
vcPush.forceUpdateVer = forceUpdateVersion
self.vc.navigationController?.pushViewController(vcPush, animated: true)
}
} else {
// Case: Current version is equal to the new version
print("Current version is up-to-date.")
vc.animateForward()
}
print("data:- ", data.forceUpdateVersion)
default:
break
}
case .failure(let error):
guard let self else{return}
self.vc.toast(msg: error.localizedDescription , time: 2)
}
}
}
// handling activity indicator
func startStopIndicator(start : Bool , hide : Bool = false){
@@ -131,3 +199,25 @@ class SplashVM{
}
}
}
extension String {
func isVersion(greaterThan version: String) -> Bool {
let versionComponents = self.split(separator: ".").compactMap { Int($0) }
let comparisonComponents = version.split(separator: ".").compactMap { Int($0) }
for (index, component) in versionComponents.enumerated() {
if index < comparisonComponents.count {
if component > comparisonComponents[index] {
return true
} else if component < comparisonComponents[index] {
return false
}
} else {
return true
}
}
return versionComponents.count > comparisonComponents.count
}
}