Dunfey · Hotel WWDC as data, est. 1983
Front desk everything
Years
Topics

2022 Audio & VideoHealth & FitnessApp Services

WWDC22 · 15 min · Audio & Video / Health & Fitness / App Services

Support multiple users in tvOS apps

Discover how you can create personalized, individual experiences in your tvOS app. We’ll show you how you can offer a single checkbox to store profile data, game save states, and more, providing each person with the same level of data separation they’d have on a personal device like iPhone. We’ll also explore how the new user-independent keychain can help you maintain your existing sign on experience for multiple people in the same household.

Watch at developer.apple.com ↗

Transcript all transcripts

Code shown on screen · 1 snippet

Save item in user independent keychain swift · at 5:25 ↗
func save(username: String, password: String) {
    guard let passwordData = password.data(using: .utf8) else {
        return
    }

    let attributes: [CFString: AnyObject] = [
        kSecAttrService: "MyApp" as AnyObject,
        kSecClass: kSecClassGenericPassword,
        kSecAttrAccount: username,
        kSecValueData: passwordData,
        kSecUseUserIndependentKeychain: kCFBooleanTrue
    ]

    let status = SecItemAdd(attributes as CFDictionary, nil)
    if status == errSecSuccess else {
        self.credentials = (username, password)
    }
}

Resources