Skip navigation
Currently Being Moderated

air 3.3 and background ios apps

Aug 13, 2012 6:17 AM

Tags: #air #ios #flash_builder_4.6

Hi All

I cannot find some coherent information on this so I am asking here.

I need to write an iOS app that needs to perform a webservice call every x minutes to update the slqite db on the device, even if the application is not running in the foreground.

 

From google what I could find out was that iOS will only allow your app to run a small time after closing(to finish an upload etc).

 

e.g. "AIR does not provide support for this iOS background processing model":  http://www.adobe.com/devnet/air/articles/considerations-air-apps-mobil e.html#articlecontentAdobe_numberedheader_5

 

but then later " applications may now support location updates and networking in the background": http://forums.adobe.com/message/4380335http://forums.adobe.com/message/4380335

 

Can I do what I need in Air 3.3+ an iOS 5.1+ ?

 

 

Thank You

 
Replies
  • Currently Being Moderated
    Oct 15, 2012 2:42 PM   in reply to kolaval

    Hi koloaval,

     

    Did you finally found a solution?

     

    According to that:

    http://help.adobe.com/en_US/air/build/WSfffb011ac560372f7e64a7f12cd2dd 1867-8000.html#WSd6d4f896b3a8801b-15a1d5f91370ecb9970-8000

     

    and that:

    http://blogs.adobe.com/airodynamics/2012/05/04/air-ios-background-beha vior/

     

    we should be able to execute task in background. But not any of my events (ENTER_FRAME, TIMER or SOUND_COMPLETE) are fired. SetTimeout neither.

     

    My config:

    Flex SDK 4.6 / AIR 3.4 / FlashDevelop / Windows 7

     

    Please let me know if you have found something.

     

    Regards

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 15, 2012 10:01 PM   in reply to Flo131313

    AIR 3.3 onwards, action script developers can execute short task in the background along with audio playback and location updates on iOS. In order to execute task in background, you would need to set

    1) NativeApplication.nativeApplication.executeInBackground = true (in action script)

    2) swf version should be 16 or more

    3) namespace should be 3.3 or more (in application descriptor)

     

    Please confirm if you have used the above settings in your app.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 16, 2012 2:48 AM   in reply to nehgupta

    Hi,

     

    I have NativeApplication.nativeApplication.executeInBackground = true in my Main.as

    I also turn this property to true on NativeApplication.nativeApplication Event.DEACTIVATE

    I compile with -swf-version=17 in my compiler options.

    I use namespace 3.4 in the manifest.

    I do my tests under iOS 6 on iPad 2, iPhone 4, iPhone 5, Acer Iconia tab/Android

     

    And in my iOS manifest:

    <key>UIApplicationExitsOnSuspend</key>

    <false/>

    <key>UIBackgroundModes</key>

    <array>

                                     <string>audio</string>

                                     <string>location</string>

    </array>

     

     

    I also tried with AIR 3.5 beta/-swf-version=18. Same issue on both Android and iOS.

     

    Do you confirm that should work? Or am I trying to do something impossible?

    Because this page says Bakground "networking". Do that mean only the pre-background loader.load calls are working in background?

     

    Regards

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 16, 2012 4:25 AM   in reply to Flo131313

    Pease confirm if you are using renderMode direct or gpu in the manifest?

    If renderMode is set to direct or gpu, execution in background won't be allowed on both Android and iOS.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 16, 2012 6:02 AM   in reply to nehgupta

    Yes I'm using Starling so I have renderMode set to direct.

     

    There's definitely no way to do background tasks using Stage3D?

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 18, 2012 5:08 AM   in reply to nehgupta

    nehgupta,

     

    Could you please reply to my last message?

     

    Thanks!

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 18, 2012 5:27 AM   in reply to Flo131313

    With Stage3D, you have to use renderMode direct and as i have mentioned earlier execution in background won't be allowed on Android and iOS in this case.

    You might want to raise a feature request for this issue.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 18, 2012 6:17 AM   in reply to nehgupta

    Thank you for your quick answer.

     

    What's the best way to raise the feature request?

     

    http://ideas.adobe.com/air redirects to http://forums.adobe.com.

    Shall I post a simple new topic?

     

    Cheers

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 18, 2012 6:42 AM   in reply to Flo131313
     
    |
    Mark as:
  • Currently Being Moderated
    Oct 18, 2012 7:22 AM   in reply to nehgupta

    When I select "Adobe AIR" in the list, I have "For feature requests, please submit ideas to the Adobe AIR Ideas website."

    And as said earlier, the link redirects to http://forums.adobe.com/ ...

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 18, 2012 7:29 AM   in reply to Flo131313
     
    |
    Mark as:
  • Currently Being Moderated
    Oct 21, 2012 9:48 PM   in reply to nehgupta

    Nehgupta, Is it possible to change the render mode during the execution of an application? As in when a user "deactivates"/"activates" the app, can the render mode be switch as to allow background execution?

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 22, 2012 3:19 AM   in reply to Spedronimo

    Spedronimo,

     

    As far as I know, you can not change the renderMode dureing execution. Only in the manifest when compiling.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 22, 2012 4:51 PM   in reply to Flo131313

    Hi ,

     

    I am facing the same behaviur, my app work fine in foreground but when I move to backgroud they go to sleep.

     

    When the app go to background I need to execute a http process each 15 secs,  i read a lot threads without find any solution.

     

    Anyone have a solution to work a simple http process in background, like how work skype?

     

    Regards,

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 22, 2012 7:04 PM   in reply to Flo131313

    I agree it seems to be the case that renderMode can't be programatically changed. What is the reason that Stage3D can't support background location/audio tasks?

     

    It's seriously crap that background execution isn't supported with 'direct' renderMode. Apart from some obscure messages on the forums like this there is nothing I've found to document that this is the case.

     

    Adobe : I would suggest that if AIR is to become a genuine mobile framework this is one of the issues that must be resolved.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 23, 2012 3:31 AM   in reply to Spedronimo

    Guys,

     

    I totally agree with you and I advise you to vote and comment the new "feature request" I raised here:

    https://bugbase.adobe.com/index.cfm?event=bug&id=3349232

     

    That will encourage Adobe to find a solution.

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 23, 2012 6:20 AM   in reply to Flo131313

    Hi,

     

    This should be great but I think adobe isn't work enough to provide a real mobile framework, this lack of information confirm that.

     

     

    Anyone can suggest me a workaround about the backrgound http proccess for a IOS app ?

     

    Regards,

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 24, 2012 2:47 PM   in reply to Peter T.R

    Hi,

     

    I already try a few workaround with the same result, the background process isn't work.

     

    I think isn't possible to run a simple http process in background on IOS.

     

    This is a terrible news for my app because they already work fine on android and playbook but how isn't possible to do on IOS?

     

    Any one have a new suggestion:

     

    Regards,

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 24, 2012 3:16 PM   in reply to Peter T.R

    Hey mate,

     

    So far as I understand it only location and audio updates are available in the background on IOS... you may be able to trick your app into working if you hooked into one of these but it might be a bit of a long shot.

     

    What we're complaining about above is that even though location and audio events are meant to be supported in IOS and Android, when the renderMode is changed to 'direct' this is not the case...

     

    A

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 25, 2012 12:18 AM   in reply to Peter T.R

    Background processing does not work if renderMode direct is used and it holds true for both iOS and Android.

     

    Please confirm if you have set "NativeApplication.nativeApplication.executeInBackground" to true in your application?

     

    You might want to refer this link for details on AIR iOS background behavior.

     

    -Neha

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 25, 2012 7:24 AM   in reply to nehgupta

    Dude,

     

    You might want to tell your posse down at Adobe that renderMode direct needs to be supported for background mode.

     

    Serious failing otherwise.

     

    A

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 25, 2012 2:05 PM   in reply to Spedronimo

    Hi,

     

    This is from adobe : Supporting background tasks on iOS

     

    Adobe AIR 3.3 and higher supports multitasking on iOS by enabling certain background behaviors:

     

    Audio

    Location updates

    Networking

    Opting out of background app execution

     

    We thing that networking is the right behavior from our apps but this seems to be for a single taks execution and we need to execute the same process each 15 secs.

     

    Any one have know how execute a http process ech x secs in background using the Networking behavior ?

    Any one know if it's possible ?

     

    Regards,

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Oct 29, 2012 11:49 AM   in reply to Spedronimo

    If you are interested in getting background tasking on iOS/Android when using Stage3D, PLEASE VOTE FOR THE FEATURE REQUEST HERE:

    https://bugbase.adobe.com/index.cfm?event=bug&id=3349232

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 1, 2012 9:05 PM   in reply to Flo131313

    voted... for what its worth.

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 6, 2012 9:50 AM   in reply to Spedronimo

    Thank you Spedronimo.

    I really hope it will be fixed soon or we'll all have to start learning another programming language...

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 28, 2012 7:33 PM   in reply to Flo131313

    So, after looking at the bug report - the status is now "closed/withdrawn" with the reasoning of "As Designed"?

     

    So Adobe, you designed this problem and have no plans to fix it?

     

    Could we get any type of answer on this?

     
    |
    Mark as:
  • Currently Being Moderated
    Nov 28, 2012 8:11 PM   in reply to shane_korin

    How could such a big hole in the background processing of the software model be 'as designed'?

     

    I would suggest this may be a big blocker to people using AIR as a platform to develop mobile apps. I know I won't be recommending it until this issue is resolved.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 3, 2012 4:45 AM   in reply to kolaval

    This really is a big bummer and I don't see how this is not a high priority issue, regardless of the implications it may have.

    Saying this is "as designed" simply shows that the design has some major flaws.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 7, 2013 9:37 PM   in reply to 5898845

    Hi People,

     

    I've reposted this as a bug... vote for it again if you think its worth the effort.

     

    https://bugbase.adobe.com/index.cfm?event=bug&id=3497587

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 19, 2013 6:22 PM   in reply to nehgupta

    Actually, I have tested in my app that, on Android at least ( didn't test on iOS ), execution in the background WILL work if renderMode = gpu, but NOT if renderMode = direct.

     

    In other words, direct appears to be the only render mode which prevents background execution.  Unfortunately, the direct render mode is necessary for the Stage3D API to work ( which I have also verified ).

     

    =================================

     

    Why this is a problem for me ( my use case ):

     

    I am making a graphical alarm clock for Android/iOS, and recently implemented full hardware acceleration via Stage3D.  On iOS, I am using local notifications to alert the user when alarm goes off and the app is minimized or closed.  Said iOS local notification is scheduled ahead of time, if the alarm has been set, when the app is deactivated. 

     

    On Android, unfortunately, I cannot use the same strategy because local notifications on this platform cannot be scheduled ahead of time.  Furthermore, with the app minimized and using direct render mode, I cannot trigger the local notification on the spot, while the app is minimized but running in the background.  So I am stuck.

     

    The right solution would be:

     

    1) Allow background execution when the direct render mode is used ( preffered ).

    2) Use an ANE for the AlarmManager on Android ( none available on the net, as of this writing ).

    3) Use push notifications:  very heavy handed ( requires server side scripting to schedule the notification ).

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 4, 2013 3:27 AM   in reply to AsterLUXman

    Hello AsterLUXman,

     

    I am new to mobile develpment and creating a reminder application for Android & IOS using Flash Builder 4.6, Air 3.1. After surfing on net I got that we need to use ANE for the Alarm manager and Push notifications for the Alerts for Android platform. I am confused for this thing. Is there any simple way to create the application in Android.

     

    Kindly Guide/Refer me for the way to develop background running application in Flash Builder 4.6.

     

    Thanks in advance.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 30, 2013 11:05 PM   in reply to Paresh Patil

    Some of the statements in this thread are no longer true, or need to be updated.

     

    Here is a recap:

     

    • As of AIR 3.9, background execution will work on iOS+Android with render mode set to 'direct' ( which implies that you are using Stage3D ).

     

    • For background execution to work in iOS, you need:

     

      • to set NativeApplication.nativeApplication.executeInBackground = true, in your as3 code somewhere ( note: strangely, background exec on iOS has worked for me in the past even by not doing that ).

     

      • to add in the iPhone section of your app manifest ( *-app.xml ):

     

        • UIApplicationExitsOnSuspend = false

     

        • UIBackgroundModes = audio ( and/or location, or some other background mode ).

     

      • a good excuse / reason :  since battery-gate on the iPhone4, Apple has  tightened its policies regarding background execution.  For example:  last time I tried, setting UIBackgroundModes=audio was only allowed if the app was intended to play a sound persistently in the background ( not occasionally, such as an alarm clock sound ).

     

    • For local notifications, I recommend Distriqt's local notification ANE ( Android+iOS), since it's the ony one I know which uses the AlarmManager api on Android ( Koesler's Android Local notif doesn't last time I checked ).  This means that on Android, the local notification can be scheduled for a later time ( same as iOS ), and will fire EVEN if the app is either minimized or has been closed properly ( meaning closed by the OS, or by the user via NativeApplication.nativeApplication.exit() -- note: force-stopping is the exception and cancels scheduled notifications on Android ).  You can also have the local notification play a custom sound which is up to 30 secs long ( mp3s on Android / cafs on iOS).  Sound will be audible on both platforms, even if the device is suspended.  This is ideal for an alarm-clock, for example.  The downside of local notifs is that they don't execute code, per se, however they can pass a data payload ( text ) back to the app, if it is running ( even if minimized ), which a handler can receive to do stuff.
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points