-
Re: Why does NSURLCredentialStorage no longer works since the update to xcode 8??
eskimo Sep 19, 2016 6:41 AM (in response to Laclass19)Why does NSURLCredentialStorage no longer works since the update to xcode 8??
It’s impossible to answer this without more information about what you’re trying to do with this class. To start, what platform are you on?
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardwarelet myEmail = "eskimo" + "1" + "@apple.com"
-
Re: Why does NSURLCredentialStorage no longer works since the update to xcode 8??
Laclass19 Sep 20, 2016 10:26 AM (in response to Laclass19)Hi. And sorry for the lack of infos.
So, i am coding for ios using objective C.
I am using this class to log in and out while saveing the credentials to autologin the user when he did not log out.
Here is the snipets for you to have an idea.
On the log in, it seems working but when i exit the viewcontroller and come back, the credentials should be checked and applied.
//LOG IN// NSURLProtectionSpace *loginProtectionSpace = [[NSURLProtectionSpace alloc] initWithHost:@"https:XXX.com" port: 443 protocol:NSURLProtectionSpaceHTTP realm:nil authenticationMethod:NSURLAuthenticationMethodDefault]; NSURLCredential *credential = [NSURLCredential credentialWithUser:_userNameLogInPlayFab.text password:_passwordLoginPlayFab.text persistence:NSURLCredentialPersistencePermanent]; [[NSURLCredentialStorage sharedCredentialStorage] setCredential:credential forProtectionSpace:loginProtectionSpace]; NSLog(@"User connected:%@ with password:%@", credential.user, credential.password);
The log out crashes the app and highlights these lines when before the update, it was working perfectly.
//LOG OUT// [[NSURLCredentialStorage sharedCredentialStorage] removeCredential:credential forProtectionSpace:loginProtectionSpace]; NSLog(@"Credential removed.");
-
Re: Why does NSURLCredentialStorage no longer works since the update to xcode 8??
eskimo Sep 21, 2016 3:26 AM (in response to Laclass19)In general, I don’t recommend that you manually stash credentials in NSURLCredentialStorage. It’s much better to respond to authentication challenges via the NSURL{Session,Connection} delegate callbacks.
However, this should work. Let’s start with the crash. You wrote:
The log out crashes the app …
What are the symptoms of this crash? If you run without the debugger, the crash should generate a crash log. Please grab that, symbolicate it, and post it here.
Technote 2151 Understanding and Analyzing iOS Application Crash Reports discusses that process in more detail.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardwarelet myEmail = "eskimo" + "1" + "@apple.com"
-
Re: Why does NSURLCredentialStorage no longer works since the update to xcode 8??
Mariano Abdala Sep 27, 2016 9:09 AM (in response to eskimo)Hi Eskimo!
I'm running into the same issue. Well, my app doesn't crash but it's not working as I'd expect ever since I upgraded to Xcode 8/Swift 2.3/iOS 10.
This is only happening on the simulator with iOS 10, but it makes me uneasy to merge this into master for all my team to work on.
I managed to strip the responsible code into a 6 lines test. Would you mind taking a look?
Test with iPhone 5s (9.3) > Pass
Test with iPhone 5s (10.0) > Fail
Test with real device (10.0) > Pass
Any ideas what may be happening? Is it safe to use this, does it seem like this is contained in the simulator?
Thanks in advance!
Mariano.
-
Re: Why does NSURLCredentialStorage no longer works since the update to xcode 8??
eskimo Sep 28, 2016 2:11 AM (in response to Mariano Abdala)This is only happening on the simulator with iOS 10 …
This probably has the same underlying cause as described in this thread. When you use
NSURLCredentialPersistencePermanent
, the credentials go into the keychain, so your test is only going work if the keychain is working. Fortunately there’s a relatively straightforward workaround, which you’ll find on the above-mentioned thread.Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardwarelet myEmail = "eskimo" + "1" + "@apple.com"
-
Re: Why does NSURLCredentialStorage no longer works since the update to xcode 8??
Mariano Abdala Sep 28, 2016 6:33 AM (in response to eskimo)Cool, thanks so much!
Adding the entitlements.plist as suggested on that thread completely fixed my issue.
-
-
-
-