Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// 1. Containing app - Store token url in the group user defaults.
DBAccount *account = [[DBAccountManager sharedManager] handleOpenURL:url];
if (account) {
NSUserDefaults *groupDefaults = [[NSUserDefaults alloc] initWithSuiteName:@""];
[groupDefaults setObject:url.absoluteString forKey:@"dropbox.token.url"];
[groupDefaults synchronize];
// 2. An Extension - Retrieve the token url from group user defaults, then give it to -[DBAccountManager handleOpenURL:] after setting "nonce".
NSUserDefaults *groupDefaults = [[NSUserDefaults alloc] initWithSuiteName:@""];
NSURL *url = [NSURL URLWithString:[groupDefaults objectForKey:@"dropbox.token.url"]];
for (NSString *pair in [url.query componentsSeparatedByString:@"&"]) {
NSArray *kv = [pair componentsSeparatedByString:@"="];
if ([kv[0] isEqual:@"state"]) {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:kv[1] forKey:@"dropbox.sync.nonce"];
[defaults synchronize];
account = [[DBAccountManager sharedManager] handleOpenURL:url];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment