Files
VibeCoding/webrtc_controller_ios/web_rtc_controller_ios/Utils/DeviceUtils.swift

22 lines
739 B
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Foundation
import UIKit
/// ID Android DeviceUtils
/// : CTRL-XXXXXXXX8
enum DeviceUtils {
private static let key = "com.ttstd.webrtccontroller.deviceId"
static func deviceId() -> String {
let defaults = UserDefaults.standard
if let saved = defaults.string(forKey: key), !saved.isEmpty {
return saved
}
let seed = UIDevice.current.identifierForVendor?.uuidString ?? UUID().uuidString
let suffix = seed.replacingOccurrences(of: "-", with: "").prefix(8).uppercased()
let id = "CTRL-\(suffix)"
defaults.set(id, forKey: key)
return id
}
}