Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix - Update deviceIdentifier to Save to Keychain #1472

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Sources/BraintreeDataCollector/BTDataCollector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,14 @@ import BraintreeCore
var item: CFTypeRef?
let status = SecItemCopyMatching(query as CFDictionary, &item)
if status == errSecSuccess,
let existingItem = item as? [String: Any],
let data = existingItem[kSecValueData as String] as? Data,
let identifier = String(data: data, encoding: String.Encoding.utf8) {
let data = item as? Data,
let identifier = String(data: data, encoding: .utf8) {
return identifier
}

// If not, generate a new one and save it
let newIdentifier = UUID().uuidString
query[kSecValueData as String] = newIdentifier
query[kSecValueData as String] = newIdentifier.data(using: .utf8)
query[kSecAttrAccessible as String] = kSecAttrAccessibleWhenUnlockedThisDeviceOnly
SecItemAdd(query as CFDictionary, nil)
return newIdentifier
Expand Down