Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sspbond007

macrumors member
Original poster
Aug 19, 2008
46
0
Hi,

Can please somebody help me, how can I make my application to run in background?
For eg. My application continuously ping server to get and send some data on the basis of user's setting. Currently when I run my application it works perfectly.I used NSTimer to perform that task repeatedly after specific time, set by user. Now if I stop the application the whole process stops, but I need is that, even after user stops the application it should not terminate. The task that is performed by NSTimer repeatedly must go on as it is. Means I just want to run my application in background, ever if user stops it or any interruption occurs, application should not terminate.

thanks
 

detz

macrumors 65816
Jun 29, 2007
1,051
0
You can't, Apple does not allow applications to run in the background.
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
9,559
6,059
Didn't Apple say you could do..

something... about the... it's always connected... and the little badge on the icon in the home screen?

I wasn't paying much attention to the keynote at that point because I had no plans for making an application that runs in the background.


I'm confused about what your application does... why does it need to be running in the background?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Didn't Apple say you could do..

No. They said that at some future point in time (should be September/firmware 2.1 but we'll see) there would be facilities for third part developers to send push notifications over the air from their own servers. Limited code stubs would be allowed to act on these notifications which would have the ability to update the badge icon. This is very different to running in the background.
 

txmike

macrumors newbie
Jul 14, 2008
12
0
So... In the future...

The way you would do this is that you would have a proxy client running on a server somewhere doing your pings. When something important happens and iPhone application needs to notified, you'll be able to send a new badge icon and a beep to the iPhone, via an Apple service, notifying the user that something important has happened and to launch the iPhone application to get the notification.

The reason for this is clear...

Background apps have a bad history on mobile devices. They chew up batteries really fast, especially if you're polling a server somewhere. Also, they tend to cause stability and performance issues.

Personally, I think Apple made the right choice here.
 

Niiro13

macrumors 68000
Feb 12, 2008
1,719
0
Illinois
You cannot run applications in the background. In the keynote, Apple was addressing push which is pretty much what SMS is. The application isn't running in the background...but when you can receive SMS while the application is closed.

This is good because if you have AIM, you don't want your buddy list to update while AIM is in the background...you don't see the list anyway! You only want it to update while you're in the application. The only thing you want in the background is receiving IMs.

As for your application, I think you can easily use push. Of course it would require some server work, but basically when the application is closed, have the server send the information to the device instead of the device pinging the server. So you'd have the server on a timer.
 

deepak832

macrumors newbie
Jun 26, 2008
28
0
Hello

I also have the same problem , i want to run my application in background, but iphone SDK not allow it.

Now i want to run my application in foreground and do my work and after that i will close my application forcefully.

But i want to know that can i invoke or open my application by using any message or alarm. Means i'll generate a alarm when i'll get my data and display a message popup for that. when user will touch on that message i want to invoke my application directly.

How can i do this please help me in that..
 

Niiro13

macrumors 68000
Feb 12, 2008
1,719
0
Illinois
I also have the same problem , i want to run my application in background, but iphone SDK not allow it.

Now i want to run my application in foreground and do my work and after that i will close my application forcefully.

But i want to know that can i invoke or open my application by using any message or alarm. Means i'll generate a alarm when i'll get my data and display a message popup for that. when user will touch on that message i want to invoke my application directly.

How can i do this please help me in that..

You cannot. The only way is if you wait until September when Apple releases push. Then you'd have to set up a whole server and stuff to push alarms to the phone.
 

deepak832

macrumors newbie
Jun 26, 2008
28
0
Thanks

Thanks for your reply and great knowledge share.
You mean before push i can't invoke my application using alarm or anything directly, rite.
Is there any alternative way to do that ? acutely i just want to invoke my application directly using alarm.

i am just trying to make you clear what i want for my application. please make me clear it again with your great knowledge.


Thanks in advance.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
There is no way to have an app start via an alarm. There are no work arounds unless you target jailbroken phones which means your app will not go on the app store
 

supertoto

macrumors newbie
Jul 29, 2008
14
0
There is no way to have an app start via an alarm. There are no work arounds unless you target jailbroken phones which means your app will not go on the app store

First, I think, according to the keynote presantation, background app is a huge power consumer, so, :apple: developed so called "Notification service", but till now, there is no any further news about when this notification service will go online.

Second, Notification service is not aim to start you app by receive a "notification", it's just a notification to the user, and show the budge icon on the right top of your app icon to notify the user that you should start this app and check for something new.

Besides, notification is really a good idea, but I still think people still have some requirement to run the application in the background no matter how much power it will consume.:rolleyes:
 

TuffLuffJimmy

macrumors G3
Apr 6, 2007
9,022
136
Portland, OR
ok, i am sorry to ask you again but i just want to read the contents of that, like using image picker we can access Photo Library , is there any way to access the contents from the audio and video library.

Acutely i want to upload the " image , or audio , or video files which is saved in my iphone" in to my server , for that i want to access that file.

Please share your grate knowledge regarding this with me.


thanks

access to that sort of information is not allowed.
 

liptonlover

macrumors 6502a
Mar 13, 2008
989
0
I accidentally found a tutorial that shows how to make your application run in the background... but he only got as far as testing and proving it works in the sim. As far as I can tell no one has done it on a device, and who knows if you could successfully get by apple. I can't find the site now...

I don't want apps running in the background. I got deep into palm programming and the device, and if you have too you know that palm apps can run in the background, and a lot do. This cause sooooooo many problems for the user and developer, it's not worth it. And also, as Jobs pointed out, then you need RAM managers and that sort of thing.
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Technical detail: exit() is in the public API's, but its use in not recommended according to the guidelines (HIG).

This is a very harsh way to exit the app: it does not cause the normal quit notifications to get called that an app would often use to save state and so on. The method I posted in the other thread does.
 

ducnm

macrumors newbie
Sep 21, 2008
6
0
why does not application run in the background.
Who can answer my question: how does iBackList work if it can not run in the background? Main feature of it is filtering incoming/outgoing calls and sms per contact
 

TuffLuffJimmy

macrumors G3
Apr 6, 2007
9,022
136
Portland, OR
why does not application run in the background.
Who can answer my question: how does iBackList work if it can not run in the background? Main feature of it is filtering incoming/outgoing calls and sms per contact

That can only be installed on Jailbroken phones. ie phones that have been hacked.
 

firewood

macrumors G3
Jul 29, 2003
8,107
1,345
Silicon Valley
why does not application run in the background.
Who can answer my question: how does iBackList work if it can not run in the background? Main feature of it is filtering incoming/outgoing calls and sms per contact

It probably isn't an app store app, uses API's not supported by the SDK, and thus won't run on any non-jailbroken devices.

Most developers in this forum only care about SDK apps.

.
 

RobertBlackburn

macrumors newbie
Oct 7, 2008
12
0
why does not application run in the background.
Who can answer my question: how does iBackList work if it can not run in the background? Main feature of it is filtering incoming/outgoing calls and sms per contact

iBlacklist works in the background because it is a jail broken application

*whoops didnt see the second page lol
 

deepak832

macrumors newbie
Jun 26, 2008
28
0
Hello

why does not application run in the background.
Who can answer my question: how does iBackList work if it can not run in the background? Main feature of it is filtering incoming/outgoing calls and sms per contact



Running app in background consumes lots of battery power that is not good for device, thats why background process is not supported and preferred not to use this process in application.
 

GoldenMonkey

macrumors newbie
Jan 1, 2009
1
0
Annoying Anti-Comments

Isn't it annoying when others dictate how your app should or shouldn't work? Why should apple limit the ability for background apps? The google phone has this ability via the ability to run services.

Yes, it causes battery performance issues. But, if for instance you want to sell an alarm clock... the user of your software needs to 'remember' to start the alarm clock up. How about reminders... oh.. the user needs to remember to start your reminder app? Sure you can use notification for some of this... but more sophisticated apps are going to need the ability to actually run code.

Apple can get away with their own 'background' apps such as their alarm clock on the iPhone. But, apple knows better than 'developers' and 'users'... this is locked down for developers and open for Apple. Let the user decide if an app should run in the background. They can remove the app if they're unhappy with the battery degradation.

~end rant.
 

firewood

macrumors G3
Jul 29, 2003
8,107
1,345
Silicon Valley
Apple can get away with their own 'background' apps such as their alarm clock on the iPhone. But, apple knows better than 'developers' and 'users'... this is locked down for developers and open for Apple. Let the user decide if an app should run in the background. They can remove the app if they're unhappy with the battery degradation.

Apple can get away with it because they wrote the app and the OS and know exactly how much memory/battery/CPU-cycles needs to be budgeted to (mostly) meet the advertised specs for an iPhone.

If users are unhappy, a very large number of them will have no clue what to remove and instead blame Apple.

.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.