Skip to content

AIR iOS – Background Behavior

Background Behavior AIR3.3 에서 새롭게 추가 된 기능입니다. iOS에서 AIR 앱이 백그라운드에서 실행 될 수 있도록 합니다. 백그라운드에서 사용 할 수 있는 기능은 다음과 같습니다.

  1. audio
  2. location

이 기능을 이용하면 음악플레이어나 트랙커 같은 앱을 구현 할 수 있습니다. 사용 방법은 다음과 같습니다.

<iPhone>
    <InfoAdditions>
        <![CDATA[
            <key>UIBackgroundModes</key>
            <array>
                <string>location</string>
                <string>audio</string>
            </array>
        ]]>
    </InfoAdditions>
</iPhone>

먼저 Main-app.xml 설정의 iPhone 부분에 UIBackgroundModes 속성을 추가합니다. 값은 배열로 location 과 audio 를 사용 할 수 있습니다. 필요한 값만 단독으로 사용 할 수도 있습니다.

NativeApplication.nativeApplication.executeInBackground = true;

as3 에서 executeInBackground 를 true 로 설정합니다.

private function initListener():void
{
	stage.addEventListener(Event.DEACTIVATE, onDeactivate);
}

protected function onDeactivate(event:Event):void
{
	NativeApplication.nativeApplication.executeInBackground = true;

	trace(NativeApplication.nativeApplication.executeInBackground); // true
}

Background Behavior는 이렇게 간단히 활성화 할 수 있습니다. 다만 주의해야 할 점이 있는데 이 기능은 renderMode 가 gpu 혹은 direct 에서는 작동 하지 않습니다. 최근에는 성능 이슈로 gpu 가속을 위해서 대부분 direct로 설정 하는데 저도 늘 이렇게 세팅을 하고 테스트를 하니 작동을 안해서 몇시간 삽질을 했네요. 참고하기 바랍니다.

참고 : http://blogs.adobe.com/airodynamics/2012/05/04/air-ios-background-behavior/

1 thought on “AIR iOS – Background Behavior”

Leave a Reply to Wolfgang Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.