Dez 13 2011

Apple rejects AIR apps which only supports one landscape mode

Tag: Actionscript,AIR,Apple,iOS,iPadKonstantin Elstner @ 00:32

These days, we tried to push a new app to the Apple App Store. It is a magazine based on AIR. After a few days of waiting we got an answer from Apple:

10.1

We found that your app does not comply with the Apple iOS Human Interface Guidelines, as required by the App Store Review Guidelines.

Specifically, we noticed your app only supported the top-right variant of the landscape orientation, but not the top-left variant.

While supporting both variants of both orientations, each with unique launch images, provides the best user experience and is recommended, we understand there are certain applications that must run in the landscape orientation only. In this case, it would be appropriate to support both variants of that orientation in your application, e.g., Home button right and left.

Addressing this issue typically requires only a simple and straightforward code modification. However, if you require assistance, theApple Developer Support Team is available to provide code-level assistance.

For more information, please review the Aim to Support All Orientations section of the iOS Human Interface Guidelines.

 

In our app settings we disabled „automatic rotation“, so the app was only supporting the landscape „top-right“ mode. This was not a problem for Apple before iOS 5, but now apps with this settings are rejected.

I think Apple is right with this decision, but also I think, Adobe should support this out of the box. Maybe in a better world, it would be so 😉

 

The solution for this problem is really simple:

import flash.events.StageOrientationEvent;
import flash.display.StageOrientation;

// enable autoRotation
stage.autoOrients = true;

// add the rotation event listener
stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGING, orientationChangingHandler);

// listener function
protected function orientationChangingHandler(e:StageOrientationEvent):void {
	// with e.afterOrientation you can get which orientation the screen would have after the rotation
	switch( e.afterOrientation )
	{
		// we want to prevent portrait modes so we stop the events
		case StageOrientation.DEFAULT:
		case StageOrientation.UPSIDE_DOWN:
			e.preventDefault();
			break;
		}
	}
}

This code will prevent that the application enters the portrait mode, if the future rotation is a portrait mode the event is stopped with e.preventDefault().

It is a good practice to set the initial autoOrients value to false in the publishing settings, otherwise the launch image will be rotated and you can not control it.

 

At this point, it is important that you do not try this code with an application which is compiled with the AIR 3.0 SDK, because, the adt compiler seems to be broken for the stage events.
If you try this code with AIR 3.0 it could be possible, that the StageOrientationEvent is never dispatched, so there seems to be a bug.

It will be working correct when you use the AIR 3.1 SDK.

It took same hours and hairs to find this annoying bug out -.-