Post marked as solved
Post marked as solved with 1 replies, 743 views
As of iOS 3.1.3, neither name nor email is returned on a physical device for repeat authorisations (but strangely, they are on the simulator). So we should explore best practices for saving them.My current solution writes them to name.txt and email.txt in the application support directory.let directoryURL = try! FileManager.default.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
let nameURL = directoryURL.appendingPathComponent("name.txt")
var name = try? String(contentsOf: nameURL, encoding: .utf8)
if let fullName = credential.fullName {
let nameFormatter = PersonNameComponentsFormatter()
let newName = nameFormatter.string(from: fullName)
if newName != "" {
name = newName
try! newName.write(to: nameURL, atomically: true, encoding: .utf8)
}
}
let emailURL = directoryURL.appendingPathComponent("email.txt")
var email = try? String(contentsOf: emailURL, encoding: .utf8)
if let newEmail = credential.email {
email = newEmail
try! email!.write(to: emailURL, atomically: true, encoding: .utf8)
}After my app successfully signs up with the backend, I delete those files. The files did disappear unexpectedly when I updated from iOS 3.1.2 to 3.1.3, but maybe that happened because my app is a development build.Are you doing it differently? Please share.Also, feel free to share solutions for web as well.