iOS: Show Users the Reason You Require Their Location

Update: iOS 6 deprecated the purpose property and it now has to be set in your Info.plist with the key NSLocationUsageDescription which is displayed in Xcode as Privacy – Location Usage Description. If you’re still supporting iOS 5 and earlier make sure you include both.

A great, but underused location feature on iOS is the purpose property of the CLLocationManager.

So many apps ask for your location – give your users confidence in sharing their location by telling them why you need it!

Example:

locationManager.purpose = @"We'll only use your location to show you local events nearby.";

You need to do this before you start the location monitoring, so:

CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.purpose = @"We'll only use your location to show you local events nearby.";
locationManager.delegate = self;
[locationManager startUpdatingLocation];

Your users will now get a pleasant reason when you request their permission:
iOS iPhone Screen Location Prompt

I’ve no idea why this is so rarely used, it’s been available since iOS 3.2.

Tip from the Apple docs:

You must set the value of this property prior to starting any location services. Because the string is ultimately displayed to the user, you should always load it from a localized strings file.

Last.fm doesn’t autostart with iTunes in Lion [Fix]

Update 04/08/2011: last.fm have updated their client, either use the Check for updates.. in the app or download it.

Still no scrobbling but the release notes show they’ve fixed it for Lion:

1.5.4.28012 (mac) (04/08/11)
—————————-
* Plugin fix for iTunes 10.5
* 64bit version of the plugin for iTunes on Lion

Original:
Sadly the last.fm client doesn’t autostart under Lion when you run iTunes; and there’s yet to be an official update. In fact the entire client has been rather neglected, seeing its last update in October 2010.

If like me, you’ve lost a bunch of scrobbles because you’ve forgotten to open it, you can add last.fm to your login items so it’ll automatically open when your Mac starts.

Open System Preferences then > Users & Groups; select your username and toggle to the Login Items page. Click the + and select the last.fm app to add to the list.

Mac System Preferences - adding last.fm to login items

If like myself, you have the last.fm not show in the dock (and only the menu bar), select the Hidden checkbox.

Unfortunately there’s no iPhone / iPad scrobbling support on Lion yet, and I’m not sure how iOS 5 WiFi sync will be able to handle it..

iOS: shouldAutorotateToInterfaceOrientation / Lock Orientation in PhoneGap

Starting in PhoneGap 0.9.5 there’s an undocumented iOS only feature that allows you to handle whether the device should rotate to a particular orientation. It exposes the iOS Objective-C method shouldAutorotateToInterfaceOrientation with a JavaScript function shouldRotateToOrientation.

function shouldRotateToOrientation (rotation) {
    switch (rotation) {
        //Portrait or PortraitUpsideDown
        case 0:
        case 180:
            return true;
        //LandscapeRight or LandscapeLeft
        case 90:
        case -90:
             return false;
    }
}

This needs to be in the global scope of your JavaScript and will get called before any rotations occur, so keep it lean to avoid locking up the UI. Returning true allows the device to rotate, returning false prevents it.

Works great in your HTML5 iOS, iPhone and iPad apps, sadly currently there’s no Android or other platform integration. Hopefully we’ll see a cross-platform method soon!

Avoid Entering Username and Passwords After Restoring iOS

If you restore your iOS (iPhone or iPad) from a backup in iTunes, you’ll find you need to re-enter your usernames and passwords for all your email accounts.

Simply tick the Encrypt iPhone Backups option in the device summary tab in iTunes and enter a password to secure your backups. iTunes will now backup and restore your sensitive data, usernames, passwords and MobileMe data, and do so securely.

Things That Give Me Usability Cramps – Web Forms

Usability Cramps

[yoo-zuh-bill-ity kramps]

  1. n. are unpleasant, often painful sensations caused by unbearable unusable user experience mistakes
  2. v. usability cramping, usability cramped, why the hell did they do this?

Form Labels That Don’t Select the Fields

This one mega-stresses me out; when the text label next to checkbox or a label doesn’t select it when you click it:

Bad Form Field:

To fix this, just give the input field an ID, and the label a for=’inputID’:


This is particularly annoying when there’s lots of checkboxes or really small radio buttons.

tip: add the following CSS to force the browser to show a pointer on clickable labels and buttons:

label, input[type="button"], input[type="submit"] {  cursor: pointer; }

Mobile Sites That Don’t Use the Right HTML(5) Input Types

If you use the correct types for your inputs then touchscreen devices adapt the keyboard to fit the need, and browsers can adjust the UI accordingly.




iOS Screenshot of email keyboard

Using input type='email' brings up an email specific keyboard on iOS

Browsers that don’t understand these new input types default to text, so you’ve got nothing to lose.

Forms That Need to Reload to Validate

It’s so easy to check your forms with a bit of JavaScript, instead of having to refresh the whole page; and generally require any password or captcha fields to be re-enter.

Oh, and if you have a username field, check it’s available before I click submit:

Twitter showing a username's available

Twitter Signup

I’m purposely not linking to any validation scripts; there’s not a universal drop in one I’d want to recommend, however, keep an eye on the native browser support for validation.