Export iOS native methods
Hi! I'm using your package, but my use case also needs to read the saved data on the Swift native part of the application. Do you think you could export the read (most important), write and other methods so that they could be simply called from the Swift code?
Did you find a way to accomplish this yet?
I'm interested in reading directly in Swift as well.
@Albert221 did you have any luck already? I need exactly your use-case.
And did you maybe already manage to do this for Android?
I was using that for iOS only app, so no experience with Android side here.
I just dig through the flutter_secure_storage native source code and reused what's there. It's more or less like this:
private func getAuthToken() -> String? {
let tokenKey = "some-token-key"
let query = [
kSecClass as String: kSecClassGenericPassword,
kSecAttrAccessGroup as String: self.getAppGroup(),
kSecAttrAccount as String: tokenKey,
kSecReturnData as String: kCFBooleanTrue!
] as [String: Any]
var dataRef: AnyObject? = nil
let status: OSStatus = SecItemCopyMatching(query as CFDictionary, &dataRef)
if status == noErr {
if let data = dataRef as? Data? {
if data == nil {
return nil
}
let result = String(data: data!, encoding: String.Encoding.utf8)!
return result
}
}
return nil
}
Okay. Does that mean that you migrated most of the code to Swift by yourself?
Sorry, what do you mean?
Ah, now I understand. All variables like kSecClassGenericPassword etc. are already existent since they're part of the key chain! Im' new to that iOS and Swift stuff, sorry :)
May I ask how you implemented the self.getAppGroup? From what I read there's no dynamic way to read the app group at runtime, at least not in a release version. Did you just hard code it?
Fixes in 6.1.0-beta.1