jsdw_ios/QuickLocation/Manager/App/AppSettings.swift

67 lines
1.8 KiB
Swift

//
// AppSettings.swift
// SHECommunity
//
// Created by Lin on 2024/12/25.
//
import UIKit
import RxSwift
import SwiftKeychainWrapper
import Network
class AppSettings: NSObject {
fileprivate static let kSharedSettingsKey = "DefaultUserSettings"
let disposeBag = DisposeBag()
static let shared: AppSettings = {
let appSettings: AppSettings
if let savedData = UserDefaults.standard.object(forKey: AppSettings.kSharedSettingsKey) as? Data,
let defaultSettings = NSKeyedUnarchiver.unarchiveObject(with: savedData) as? AppSettings {
appSettings = defaultSettings
} else {
appSettings = AppSettings()
}
appSettings.uuid = appSettings.getUUID()
return appSettings
}()
/// AppStore ID
var appId: String { "" }
/// UUID
var uuid: String = ""
/// UniversalLink
public static let kAppsUniversalLink: String = "https://api.xxxx.com/xxxx/"
// MARK: - SDK Key
///
public static let kAppsAMapAppId = "4f6b29cfedc0e117316b88008fa41c07"
/// wechat
public static let kAppsWXApiAppId = "wx9c91710269dcd0cf"
///
public static let kAppsAlipayAppId = "2021005110694730"
///
public static let kAppsGeTuiAppId = "cYHNI4KThh6SxZUsf9RiU2"
}
// MARK: - UUID & Keychain
extension AppSettings {
private func getUUID() -> String {
if let retrievedString = KeychainWrapper.standard.string(forKey: "ShareUUIDKey") {
return retrievedString
}
return saveUUID()
}
private func saveUUID() -> String {
let uuid = UIDevice.current.identifierForVendor!.uuidString
let saveSuccessful: Bool = KeychainWrapper.standard.set(uuid, forKey: "ShareUUIDKey")
return saveSuccessful ? uuid : ""
}
}