iOS SDK for Userbin

Use this SDK to authenticate your users through Userbin in your IOS application.

Installation and configuration

Clone the repo from Github and open Userbin Example.xcodeproj

git clone git@github.com:userbin/userbin-ios-example.git

Configure the Userbin module in AppDelegate.m with the credentials you got from signing up. The domain is optional, and specifies where the authentication cookies are set, thus shall be the backend you'll be calling from the app.

[Userbin configureWithAppId:@"YOUR_APP_ID"
                  apiSecret:@"YOUR_API_SECRET"
                     domain:@"yourserver.com"];

Now press Run and you should be all set.

Authenticating users

Opens the log in dialog and invokes the callback when the user successfully logs in. Set closable to YES to add a close button to the view.

[Userbin logInWithViewController:self closable:NO completionHandler:^{
  // logged in, now fetch stuff from your server
}];

Same thing for sign up:

[Userbin signUpWithViewController:self ...]

Returns the Userbin profile for the currently logged in user as a NSDictionary

if ([Userbin isLoggedIn]) {
  NSDictionary *profile = [Userbin profile];
  NSString *email = [profile objectForKey:@"email"];
}

Logs out the user:

[Userbin logOut];

Authenticating towards your own server

If you want a user to access a protected resource on a server using Userbin, request it as a logged in user. An authenticated cookie will automatically be sent along with all requests, letting the user access protected paths on your server.

The domain in the request URL must match the domain set in the configuration step

NSMutableURLRequest *request =
   [NSMutableURLRequest requestWithURL:[NSURL
                         URLWithString:@"http://yourserver.com/protected"]];

[NSURLConnection
  sendAsynchronousRequest:request
                    queue:[NSOperationQueue mainQueue]
        completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
            // use the authenticated data from your server
}];

Admin dashboard

With Userbin you get an admin dashboard out of the box.

  • Invite, update, remove and ban users
  • Log in as any of your users for debugging
  • Configure user validation, access rights and login methods
  • See who is using your web or mobile app in real-time.
  • Customize copy and appearance of your transactional emails.