Keychain Services API允许添加/更新/删除钥匙串中的项目。但是,它似乎没有包含任何机制来监视特定的钥匙串项的更改。
我的应用程序正在钥匙串中存储一个值,如果该值被用户或其他进程更改,我想得到通知。这是可能的,还是我只需要定期轮询钥匙串项并自己检查是否更改?
这里是您所用的安全框架API
/**
@function SecKeychainAddCallback
@abstract Registers your keychain event callback function
@param callbackFunction A pointer to your keychain event callback function, described in SecKeychainCallback. You indicate the type of keychain events you want to receive by passing a bit mask of the desired events in the eventMask parameter.
@param eventMask A bit mask indicating the keychain events that your application wishes to be notified of. See SecKeychainEventMask for a description of this bit mask. The Keychain Manager tests this mask to determine the keychain events that you wish to receive, and passes these events in the keychainEvent parameter of your callback function. See SecKeychainEvent for a description of these events.
@param userContext A pointer to application-defined storage that will be passed to your callback function. Your application can use this to associate any particular call of SecKeychainAddCallback with any particular call of your keychain event callback function.
@result A result code. See "Security Error Codes" (SecBase.h).
*/
public func SecKeychainAddCallback(_ callbackFunction: SecKeychainCallback,
_ eventMask: SecKeychainEventMask,
_ userContext: UnsafeMutableRawPointer?) -> OSStatus