Skip to main content
Participating Frequently
June 28, 2011
Answered

How to quit/exit an iOS app?

  • June 28, 2011
  • 17 replies
  • 27710 views

NativeApplication.nativeApplication.exit() does not seem to work on iPad!

Using sdk 2.7, it works fine on Flash builder, but once deployed to an iDevice nothing happens, the app does not quit!.

I've already included the extra key in the iPhone InfoAdditions:

<key>UIApplicationExitsOnSuspend</key>

<string>YES</string>

Still no dice... I have to force quit the app via the double-tap-Home trick.
Any ideas/suggestions welcome.
julio

This topic has been closed for replies.
Correct answer sanika Kulshreshtha

just an addition to this thread, the exact same app installed on Android does quit gracefully, so this is an iOS thing.


Hi,

iOS does not provide a way to exit the application. So it is expected that nativeApplication.exit() won't work on iOS and it does on Android.

One question, how are you making sure that you application is not relaunching? The fact that you see it on double-tap Home does not mean that it did not exit. This is because double-tap Home in iOS 4 gives you a list of recently launched applications.

Hope that helps.

Thanks,

Sanika

17 replies

Participant
January 17, 2012

Awesome! Nice to know that 2 days of testing means I am not crazy and it just doesn't work. Excellent. Truly, now I can move on with a solution.

Known Participant
June 16, 2012

Hi there,
I have iPad 2 and iOS version is 5.1.
I have added the following code under application initialize:

protected function application1_initializeHandler(event:FlexEvent):void
{
// TODO Auto-generated method stub
NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, onDeactivateApp);

}

protected function onDeactivateApp(event:Event):void
{

NativeApplication.nativeApplication.exit();
}

And added ‘UIApplicationExitsOnSuspend’ key under InfoAdditions of iPhone, under app descriptor xml file (I set, 'UIApplicationExitsOnSuspend' key to  'true' under iPhone's 'InfoAdditions' ):

"

<iPhone>

        <InfoAdditions><![CDATA[

            <key>UIDeviceFamily</key>

            <array>

                <string>1</string>

                <string>2</string>

            </array>

            <key>UIApplicationExitsOnSuspend</key>

            <true/>

        ]]></InfoAdditions>

        <requestedDisplayResolution>high</requestedDisplayResolution>

    </iPhone> "

This worked perfectly fine for me. Application completely exits on hitting the ‘exit\home’ key of ipad. Next time I tap on the app, it initializes from beginning! Thanks for the post. Hope this helps others too.

gingerman
Participating Frequently
September 27, 2012

Hello megharajdeepak,


Thanks for the information.

Is there any chance that you could post the whole XML document for me as I am getting errors when I compile?

Here is the error attached.

Thanks

Steve



Participating Frequently
June 29, 2011

Hi,

@Julio

is your application frozen or in supsended state? If no - but you're facing "bad" state in your application you need to handle that state in such way that while supporting multitasking - your application is reset to "proper" state - as there is no support on iOS for programmatic termination (so native application cannot just terminate itself).

http://developer.apple.com/library/ios/#qa/qa1561/_index.html

hth,

regards,

Peter

juliojfcAuthor
Participating Frequently
June 30, 2011

Oh no, the application is not frozen or anything, it just does not close when I execute a "NativeApplication.nativeApplication.exit()", as it should and as the documentation says.

The application just keeps running!

I know that iOS apps do not quit in general, you just hit Home and fire up something else. But this is an internal enterprise kind of app, that taps into the corporate database and should not stay on and connected all the time. Users need to 'quit'...

Anyway, I believe we may have to adapt it to behave like any other app, sign  off and stay on, and ready to sign back in again, much like skype, facebook,viber and others... maybe it is time to switch paradigms from you run-of-the-mill corporate database mentality :-(

cheers,

julio

juliojfcAuthor
Participating Frequently
June 30, 2011

just an addition to this thread, the exact same app installed on Android does quit gracefully, so this is an iOS thing.

Participating Frequently
June 29, 2011

Hi,

Could you try with the following syntax?

<key>UIApplicationExitsOnSuspend</key>

<true/>

Thanks,

Sanika

juliojfcAuthor
Participating Frequently
June 29, 2011

Did that, still no dice. (found that tip here at DevGirls http://devgirl.org/2011/06/24/exit-vs-suspend-your-ios-application/)

This is on an iPad 2, running the latest iOS.

I did check the .ipa's Info.plist and the setting is there is a Boolean=Yes!

Using prior syntax the value showed up as String.

So the setting does make it into the ipa, but iOS simply ignores it!

Thanks anyway Sanika.