Files
voice-cat/clients/apple/iOS/VoiceCatiOS/BroadcastCredentials.swift

22 lines
761 B
Swift
Raw Normal View History

import Foundation
struct BroadcastCredentials: Codable {
var host: String
var port: Int
var authMode: String
var username: String
var tofuPinsPath: String
static func loadFromAppGroup() -> BroadcastCredentials? {
let groupId = "group.cat.voice.VoiceCat"
guard let container = FileManager.default.containerURL(
forSecurityApplicationGroupIdentifier: groupId)
else { return nil }
let url = container
.appendingPathComponent("voicecat", isDirectory: true)
.appendingPathComponent("broadcast_credentials.json")
guard let data = try? Data(contentsOf: url) else { return nil }
return try? JSONDecoder().decode(BroadcastCredentials.self, from: data)
}
}