Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Customizing Interface Elements

Caleb Davenport edited this page Jan 22, 2014 · 3 revisions

Most SimpleAuth providers need to present user interface elements to the user. For example, the Twitter provider shows a UIActionSheet if the user needs to select an account from a list. Likewise, the Tumblr provider needs to show a view controller so that the user can log in to the Tumblr website.

You can customize behaviors such as these by configuring the SimpleAuthPresentInterfaceBlockKey and SimpleAuthDismissInterfaceBlockKey for a given provider. Each of these blocks accepts a single argument and has no return value.

You can configure this globally if you like:

SimpleAuthInterfaceHandler handler = ^(UIViewController *controller) {
    MyCustomNavigationController *navigation = [[MyCustomNavigationController alloc] initWithRootViewController:controller];
    UIViewController *root = [[[[UIApplication sharedApplication] delegate] window] rootViewController];
    [root presentViewController:navigation animated:YES completion:nil];
};
SimpleAuth.configuration[@"tumblr"] = @{
    // consumer_key and consumer_secret
    SimpleAuthPresentInterfaceBlockKey : handler
};

Although, it may be better to configure this on a single authentication since you have more context:

SimpleAuthInterfaceHandler handler = ^(UIViewController *controller) {
    MyCustomNavigationController *navigation = [[MyCustomNavigationController alloc] initWithRootViewController:controller];
    [self presentViewController:navigation animated:YES completion:nil];
};
NSDictionary *options = @{
    SimpleAuthPresentInterfaceBlockKey : handler
};
[SimpleAuth authorize:@"tumblr" options:options completion:^(id responseObject, NSError *error) {}];
Clone this wiki locally