Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

glucode/GLCKeychainWrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GLCKeychainWrapper

CI Status Version License Platform

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

GLCKeychainWrapper is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "GLCKeychainWrapper", :git => 'https://github.com/glucode/GLCKeychainWrapper.git', :branch => 'master'

Using GLCKeychainWrapper

Adding items to Keychain

Without any access control

[GLCKeychainWrapper setData:data forKey:@"username" accessControl:nil serviceName:@"com.glucode.GLCKeychainWrapper" completion:^(GLCKeychainWrapperResult result) {
    if (result == GLCKeychainWrapperResultSuccess) {
        NSLog(@"Successfully added item");
    }
}];

With Touch ID access control

SecAccessControlRef sac = [GLCKeychainWrapper touchIDCurrentSetWhenUnlockedThisDeviceOnlySAC];
[GLCKeychainWrapper setData:data forKey:@"username" accessControl:sac serviceName:@"com.glucode.GLCKeychainWrapper" completion:^(GLCKeychainWrapperResult result) {
    if (result == GLCKeychainWrapperResultSuccess) {
        NSLog(@"Successfully added item");
    }
}];

Reading items from Keychain

[GLCKeychainWrapper stringForKey:@"username" serviceName:@"com.glucode.GLCKeychainWrapper" completion:^(GLCKeychainWrapperResult result, NSString * _Nullable value) {
   
   NSLog(@"%@", value);
   
}];

Author

Nico du Plessis, [email protected]

License

GLCKeychainWrapper is available under the MIT license. See the LICENSE file for more info.