0

I'm building an action extension for my iOS app. However, I'm having some real difficulties with handling user data. In my app I'm storing the user's username and password like this:

 KeychainItemWrapper *keychainItem = [[KeychainItemWrapper alloc] initWithIdentifier:@"testapp" accessGroup:nil];

[keychainItem setObject:[self.txtUsername text] forKey:(__bridge id)(kSecAttrAccount)];
[keychainItem setObject:[self.txtPassword text] forKey:(__bridge id)(kSecValueData)];

NSString *valueToSave = @"Remembermebycredentials";
[[NSUserDefaults standardUserDefaults] setObject:valueToSave forKey:@"RememberMe"];
[[NSUserDefaults standardUserDefaults] synchronize];

How can I access this from my action extension? I tried retrieving it with the same identifier and creating a shared container, but that didn't work...

Wain
  • 118,658
  • 15
  • 128
  • 151
user4334509
  • 125
  • 2
  • 10

1 Answers1

0

You can not access the saved data from your app until you make access group.You need to configure application for access group it is not directly available to your extension as your extension is different process.

I recommend to follow a tutorial and WWDC Session

Creating App Extensions for iOS and OS X, Part 1

Creating App Extensions for iOS and OS X, Part 2

codester
  • 36,891
  • 10
  • 74
  • 72