My name is Jake Marsh.
I'm a developer, designer, and writer.

Subscribed via Push Notifications. You can also subscribe via RSS or Twitter.

Subscribe via RSS or Twitter.

Subscribe via Push Notifications, RSS or Twitter.

▸ Delight Your Users By Pre-filling Forms With JBDeviceOwner

 •  3 minutes to read

Filling out forms on a phone can really suck. Heck, even on the iPad's awesome screen, I often make plenty of mistakes while typing in information.

When a user first downloads your iOS app, it's quite common for them to need to fill out some sort of "sign up" or some other kind of form.

All of this can add up to a terrible "first run" experience for new users of your app.

What's a developer to do?

Enter: JBDeviceOwner

This simple library, which comes to us from Jake Boxer, uses the name of the user's device to look up and return commonly needed user information from their Address Book record.

Here's what it looks like in action:

JBDeviceOwner *owner = [UIDevice currentDevice].owner;

// owner will be nil if the user's data could not be found.
if (owner != nil) {
  self.firstNameTextField.text = owner.firstName;
  self.lastNameTextField.text  = owner.lastName;
  self.emailTextField.text     = owner.email;
  self.phoneTextField.text     = owner.phone;
}

Jake describes how it works:

It's really simple actually.

Most iPhones are named "Jake Boxer's iPhone" ("sometimes with a different person's name instead of mine). Most iPhones have their owner saved in their address book.

JBDeviceOwner extracts the owner's name from the device name, finds the matching record in the address book, and populates the JBDeviceOwner instance with the data from the record.

If JBDeviceOwner can't figure out the owner's name, or if it can't find a matching record in the address book, it won't return anything.

Obviously this approach, while really neat, isn't going to work for absolutely every user, so you should have a sensible "fall back". I like to "try grabbing" using JBDeviceOwner, and if I don't find anything, try manually asking the user to enter their email, then using that email address to try to locate their contact record.

Try not to over-do it, but I believe when done well, this sort of approach can be an awesome alternative to requiring users to type in a ton of information.

Please Note: Try not to ask your users for a ton of information in the first place, only require what you absolutely need to make your app work.

That being said, A few big name apps are now using this technique, and their "first run" experiences are much nicer, simply prompting the user with a UIActionSheet with, for example: "Would you like to use this information?"

Check out JBDeviceOwner on Github and stop annoying your users today!

Vote on Hacker News