问题
I am making a IOS custom keyboard extension. By default the keyboard has limited functionality, but when the user purchases the full version from the main parent app then the keyboard unlocks the missing parts.
To check if the user has purchased the app I try to store a Bool
in the IOS keychain using this library.
let IAPKeychain = Keychain(service: "com.roymunsonstudios.CopypastaKeyboard")
var purchase: Bool = true
let purchaseData = NSData(bytes: &purchase, length: sizeof(Bool))
try! IAPKeychain.set(purchaseData, key: identifier)
I then try to access the keychain from my keyboard extension in the viewDidLoad
method like this:
let IAPFetch = Keychain(service: "com.roymunsonstudios.CopypastaKeyboard.Copypasta")
print("Just finished creating keychain instance")
do {
let purchaseStatusData = try IAPFetch.getData("com.roymunsonstudios.CopypastaKeyboard.FullVersionKeyboard")
}
catch is ErrorType {
print("Error fetching data")
}
However, whenever I try to do this I get the following error:
OSStatus error:[-25291] No keychain is available. You may need to restart your computer.
I am not sure what is wrong. I have turned on keychain sharing in the extension and the main app and I have the same keychain group name in each target (the keychain group name is the extension's bundle ID).
Why is this error occurring?
来源:https://stackoverflow.com/questions/38555764/get-no-keychain-available-error-when-try-to-access-keychain-from-app-extension