New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do i store other info in keychain except username and password #36
Comments
You can serialize what you need to json and save it as the password. Then On Oct 19, 2016 07:56, "Jeremy He" notifications@github.com wrote:
|
Ok, makes no sense to me, but seems like it's a only way |
I would love to have a feature like this. Storing key-value pairs would be a huge plus. I wish there was a function like |
@dannyharding10 That's the exact feature i wanted |
Is there an actual practical difference between the two?
I believe you can achieve the same end result by just using the generic password approach. I'm interested to know any challenges you find with this though, as this is one of the use cases I'm about to implement on an app. |
One challenge would be if your app interfaced with multiple APIs and it had to store a token for each one. You could only store one or two in the generic password. There would be ways to get around this, but they're not great solutions because it would make the code hard to understand. I ended up using the generic password myself because I only had to store one token, but this is still not optimal because generic password is meant for storing a username and a password pair. |
I agree with you, guys. It'd be great to have a simple API to store a key-value pair. |
As answered @vonovak you can just serialize your data (like JSON.stringify) to store any key-value data. |
Hey, @MacKentoch, thanks for answering. My problem is not storing an object, but to store some info (a string, a stringified object...) under a certain key so I can retrieve it later, easily. What I'm doing right now is: Keychain.setInternetCredentials('KEY', 'RANDOM_STUFF', 'value').then(() => console.log('Done'))
Keychain.getInternetCredentials('KEY').then(({ password }) => console.log('Got it', password)) but ideally we need Keychain.setValueForKey('KEY', 'value').then(() => console.log('Done'))
Keychain.getValueForKey('KEY').then(value => console.log('Got it', value)) I don't know if I'm doing it in a good way, or if there is a better one with the current API. Thanks. |
@danielmartinprieto I had this kind of need. I just used optional parameter function getGenericPassword(
service?: string
): Promise<boolean | {service: string, username: string, password: string}>;
function setGenericPassword(
username: string,
password: string,
service?: string
): Promise<boolean>; |
Cool! I think I will use your version because I find Thanks! |
So guys... is this a |
This can be very helpful. |
closing, as the question is answered in #36 (comment) |
could it support to store other custom property like 'token', 'certification' or any other info rather than username and password?
As i see now it only supports these two properties which is a restriction to us
The text was updated successfully, but these errors were encountered: