1

I'm developing an iPhone application that I want to run in the background. Stack Overflow, tell me, what do I have to change in the application's info.plist?

Any help would be appreciated, I'm not very familiar with this technology. Thanks.

Chris Eberle
  • 47,994
  • 12
  • 82
  • 119
naresh
  • 107
  • 10
  • Possible duplicate of [Is it possible to run accelerometer of iphone in background](http://stackoverflow.com/questions/2294985/is-it-possible-to-run-accelerometer-of-iphone-in-background) – raaz Jun 22 '11 at 06:24

3 Answers3

1

You can set UIApplicationExitsOnSuspend as falsein your info.plist to achieve this behaviour.

raaz
  • 12,410
  • 22
  • 64
  • 81
  • Sir,after entering to background,is ther any possibility for finding the x,y,z axis values in the background. – naresh Jun 22 '11 at 05:39
  • Once your application enter into background state it is actually moved to the suspended state shortly thereafter. While in this state, the application does not execute any code and may be removed from memory at any time.So inorder to get any value while your application is in background needs some types of background execution & this must be declared in advance by the application that uses them.You can refer this: http://developer.apple.com/library/ios/#documentation/iphone/conceptual/iphoneosprogrammingguide/BackgroundExecution/BackgroundExecution.html#//apple_ref/doc/uid/TP40007072-CH5-SW6. – raaz Jun 22 '11 at 06:03
  • UIApplicationExitsOnSuspend is not available in info.plist – naresh Jun 22 '11 at 06:26
  • Right click upon info.plist & Open it in xml format.Now write & save UIApplicationExitsOnSuspend – raaz Jun 22 '11 at 06:30
  • Now after saving this will show as "Application does not run in background" followed by an empty checkbox. – raaz Jun 22 '11 at 06:35
  • s.it shows.If we check then application is not running in the background.am i correct – naresh Jun 22 '11 at 06:39
  • Yes, if you checkmark this checkbox or UIApplicationExitsOnSuspend then your application do not run in background. – raaz Jun 22 '11 at 06:54
  • how much time the application can run on background – naresh Jun 22 '11 at 06:57
  • You can't run an application in the background for an indefinite time.You can refer to previously mentioned URL to check what kind of application has such permission. – raaz Jun 22 '11 at 07:10
  • So we cant run any application in the background.Only that url specified applications can run on background.Am i correct – naresh Jun 22 '11 at 07:14
  • Just refer the previous mentioned URL for more details. – raaz Jun 22 '11 at 07:15
  • Yes, if you want to launch your application in appstore ;) – raaz Jun 22 '11 at 07:18
0

In info.plist add a new tag by clicking the plus symbol. It lists you all the other options you have. There you will have "Application does not run in background". Check or uncheck on the box as you need. So that it allows or doesn't allows your app to run in background.

Saranya
  • 1,481
  • 3
  • 14
  • 26
0

You can do nothing for this. ios 4.0 and later provide this functionality by default and you cant do any thing with lower one.

Ishu
  • 12,797
  • 5
  • 35
  • 51
  • Sir,is there any possibility for finding the x,y,z axis values in the background. – naresh Jun 22 '11 at 05:31
  • What do you mean by background. Background thread within the app or whole app in background – Ishu Jun 22 '11 at 05:32
  • I dont think so, but when you come from background then you need to find the x,y and z axis values.use this method - (void)applicationWillEnterForeground:(UIApplication *)application – Ishu Jun 22 '11 at 05:40
  • or this method - (void)applicationDidBecomeActive:(UIApplication *)application – Ishu Jun 22 '11 at 05:40
  • I want to find out the axis values when the application is went to background. – naresh Jun 22 '11 at 05:42
  • ok then use - (void)applicationWillResignActive:(UIApplication *)application or - (void)applicationDidEnterBackground:(UIApplication *)application – Ishu Jun 22 '11 at 05:44
  • In that i use the uiacceleration for finding the x,y,z axis values.But it gives the result as 0 for x,y,z – naresh Jun 22 '11 at 05:46
  • Then you need to check your accelerometer methods. – Ishu Jun 22 '11 at 06:07
  • That methods are not fired when the application is in background. – naresh Jun 22 '11 at 06:24
  • humm that will not call when your app is in background what you need you need to store the coordinates in NSUserDefaults when your control reach in - (void)applicationWillResignActive:(UIApplication *)application method.(at this time your app is going in background but still in foreground).make global variable for showing x,y and z and each time save values in it. then you can access these variables in applicationWillResignActive method, now here you can save these in user defaults for further use.Hope you can understand what i am trying to describe. – Ishu Jun 22 '11 at 06:34
  • Ok.we save that values in the userdefaults.And next one is compare that values every time with device x,y,z axis values. – naresh Jun 22 '11 at 06:56
  • dont save these values in user defaults each time save when you are going in background.when you are foreground you can use the class level variables. – Ishu Jun 22 '11 at 07:05
  • But in background uiaccelerometer delegate method was not fired for getting the x,y,z axis values – naresh Jun 22 '11 at 07:07