Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed a bug where installing multiple Mac apps with the Pocket SDK wo…

…uld cause keychain keys to be in conflict

Steps to reproduce:
1. Install a 3rd-party app with the Pocket SDK
2. Login
3. Build and run the test app under the Release configuration
4. The app should not be logged in, try to access other keychain items, or return a 137 error from the Pocket API
  • Loading branch information...
commit f717bac8f245ba1baea5e2bedcf8619cb6f30da5 1 parent 245520d
Steve Streza authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 SDK/PocketAPI.m
View
8 SDK/PocketAPI.m
@@ -643,17 +643,21 @@ -(NSString *)pkt_deviceOSVersion{
@implementation PocketAPI (Credentials)
+#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
#define PocketGlobalKeychainServiceName @"PocketAPI"
+#else
+#define PocketGlobalKeychainServiceName [NSString stringWithFormat:@"%@.PocketAPI", [[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString *)kCFBundleIdentifierKey]]
+#endif
-(void)pkt_setKeychainValue:(id)value forKey:(NSString *)key{
if(value){
-#if TARGET_IPHONE_SIMULATOR || (DEBUG && !TARGET_OS_IPHONE)
+#if TARGET_IPHONE_SIMULATOR || (DEBUG && !TARGET_OS_IPHONE && TARGET_OS_MAC)
[[NSUserDefaults standardUserDefaults] setObject:value forKey:[NSString stringWithFormat:@"%@.%@", PocketGlobalKeychainServiceName, key]];
#else
[SFHFKeychainUtils storeUsername:key andPassword:value forServiceName:PocketGlobalKeychainServiceName updateExisting:YES error:nil];
#endif
}else{
-#if TARGET_IPHONE_SIMULATOR || (DEBUG && !TARGET_OS_IPHONE)
+#if TARGET_IPHONE_SIMULATOR || (DEBUG && !TARGET_OS_IPHONE && TARGET_OS_MAC)
[[NSUserDefaults standardUserDefaults] removeObjectForKey:[NSString stringWithFormat:@"%@.%@", PocketGlobalKeychainServiceName, key]];
#else
[SFHFKeychainUtils deleteItemForUsername:key andServiceName:PocketGlobalKeychainServiceName error:nil];
Please sign in to comment.
Something went wrong with that request. Please try again.