Status Barred: iOS Screenshot Status Bar Remover App

So many iOS apps developers forget to remove the screenshots from their apps on the App Store; often revealing the horrendous times the screenshots were taken and detracting from the actual app.

iTunes Connect recommends the removal of the status bar, and Status Barred removes the status bar perfectly regardless of the screenshot being retina, iPhone, iPad, landscape or portrait. For $0.99 it saves a bunch of time whenever submitting or updating an app.

Available on the Mac App Store

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.

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!

Javascript – Is an Object Empty?

To check if an object is empty in Javascript:

Object.getOwnPropertyNames(obj).length === 0;

Where obj is the object you’re testing e.g.:

var obj = {};
Object.getOwnPropertyNames(obj).length === 0; //true
obj = {'not' : 'empty'};
Object.getOwnPropertyNames(obj).length === 0; //false

Or to wrap it in a function:

function isEmpty(obj){
    return (Object.getOwnPropertyNames(obj).length === 0);
}

This only works in ECMAScript 5 compatible browsers, so is useful when developing mobile / desktop web apps.