sameerkapps / SecureStorage

118 stars 32 forks source link

IOS KeyChain not saving value, xcode 9 #31

Open Doublebock opened 6 years ago

Doublebock commented 6 years ago

Hi, I've been using the SecureStorage plugin on Android and UWP and it has been working fine. I just started testing IOS but the plugin/keychain only returns empty values. xcode 9, iphone 8 simulator. Custom Entitlements is not set. (Setting this causes a profiling error I cannot resolve at this time.)

I found this and wondered if it's related. https://forums.developer.apple.com/thread/87449. I am accessing the plugin for a portable library which seems different situation than their unit test issues.

Following is a clip of the code. SetValue does return false. value = "test"; var r = CrossSecureStorage.Current.SetValue(key, value); var v = CrossSecureStorage.Current.GetValue(key); if ( v != value ) throw new Exception("R: " + r + ", Value: " + (v ?? "(null)") + ", orig: " + (value ?? "(null)"));

Output: R: False, Value: (null), orig: test

Hopefully, it's a mistake I am making; if so, I apologize for taking your time.

Thanks

ghost commented 6 years ago

Having the same issue, I'm currently using version 2.0.0. Tried downgrading to another version but the issue seems to remain.

sameerkapps commented 6 years ago

Does it work on the iPhone/iPad, but not on the simulator? If so, it can be this issue: https://github.com/sameerkapps/SecureStorage/issues/9

ibrahimmd90 commented 6 years ago

For those who still face troubles, follow these steps: 1- Right click on the iOS project, click Options. 2- Custom Entitlements: Entitlements.plist Custom Resource Rules: Info.plist image

3- Done. It should work now.

I assumed that you already checked Enable Keychain in Entitlements.plist: screen shot 2018-02-16 at 2 58 14 pm

sameerkapps commented 6 years ago

Thanks @ibrahimmd90 for your input. @NielsWillems @Doublebock if this issue is addressed, please close it.

ValonK commented 6 years ago

The Issues still affects me even after I completed the steps you mentioned.

iPhone X iOS 11.2 Simulator Xamarin.Forms 2.5.0.280555 SecureStorage 2.0.1

ghost commented 6 years ago

@sameerkapps After creating a test project in Xcode to generate a provisioning profile for the identifier it seems to be working on the simulator as well. I already had the keychain access group + custom entitlements set up. Cheers!

Dodda commented 6 years ago

@sameerkapps I am also facing the same issue, Get always return null, I am using iOS Simulator 11.3 and Secure Storage Version 2.0.2. Please help me.

sameerkapps commented 6 years ago

Please check the latest package 2.5.0. It sets KeyChain access level at AfterFirstUnlock as default.

devinZhou102 commented 6 years ago

I am facing the same issue, I am using iOS Simulator 11.3 and Secure Storage Version 2.5.0.

RudolfVonKrugstein commented 6 years ago

Same here

thj-dk commented 6 years ago

Same :-)

codebeaulieu commented 6 years ago

Having the same issue running v 2.5.0. NetStandard 2. Entitlements enabled as described above.

sameerkapps commented 6 years ago

I tried Secure Storage sample with iOS Simulator 11.3, secure storage 2.5.0 and Xamarin forms 3.0.0.482510. Could not repro with the sample. Have you tried using secure storage sample? Also, can you please upload/send me the one that does not work? Thanks.

PlymouthRock commented 6 years ago

I was having the same issue. Installed my application using Secure Storage v 2.0 with a password.

Then updated the application to v 2.5 without a password. Could not retrieve values from Secure Storage.

Deleting the application did not resolve the problem. I believe this is because iOS does not remove the keychain even when the application is uninstalled.

I use a iPod for my test device. I did a device wipe and reinstall. Problem solved!