PDA

View Full Version : how can I make my application to run in background???




sspbond007
Aug 27, 2008, 07:07 AM
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
Aug 27, 2008, 07:08 AM
You can't, Apple does not allow applications to run in the background.

ArtOfWarfare
Aug 27, 2008, 07:19 AM
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
Aug 27, 2008, 07:22 AM
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
Aug 27, 2008, 03:46 PM
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.

nnfaris5
Aug 27, 2008, 06:01 PM
it is not available but it will be soon as what they said..

Niiro13
Aug 27, 2008, 06:15 PM
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
Aug 29, 2008, 08:15 AM
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
Aug 29, 2008, 09:35 AM
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.

mccannmarc
Aug 29, 2008, 09:52 AM
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.

although the recent death of steve jobs may delay push release date ;) haha

deepak832
Aug 30, 2008, 01:23 AM
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
Aug 30, 2008, 02:06 AM
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
Sep 1, 2008, 01:42 AM
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
Sep 6, 2008, 01:05 AM
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
Oct 15, 2008, 11:14 AM
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.

firewood
Oct 15, 2008, 11:24 AM
There is no officially supported way in the SDK so the only answer involves calling a non-public method.

Technical detail: exit() is in the public API's, but its use in not recommended according to the guidelines (HIG).

robbieduncan
Oct 15, 2008, 11:27 AM
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.

firewood
Oct 15, 2008, 11:27 AM
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.

The Simulator allows background processes. They won't work on an actual (non-jailbroken) device.

ducnm
Oct 15, 2008, 11:30 PM
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
Oct 15, 2008, 11:56 PM
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
Oct 16, 2008, 12:00 AM
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
Oct 16, 2008, 12:40 PM
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
Oct 16, 2008, 11:48 PM
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
Jan 1, 2009, 09:20 AM
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
Jan 1, 2009, 03:23 PM
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.

.

mitchellg01
Jan 11, 2010, 10:21 PM
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

Get an app called dockless. If you download that as well and select that app to run in the background it will do it for you

robbieduncan
Jan 12, 2010, 04:26 AM
Get an app called dockless. If you download that as well and select that app to run in the background it will do it for you

Note that this forum is for iPhone Programming. Your suggestion will not work (and does not even make sense on an iPhone)

txmike
Jan 12, 2010, 04:31 AM
Sorry dude,

But this is a limit of the platform.

You cannot create a task that runs in the background.

At least not legally and make it on to the app store.

Apple made this decision for a variety of reasons, primarily because it would impact performance and security of the device. For example, we have an app that needed to do it, our Windows Mobile guy figured out how to do it and the client was very happy with him, and not so happy with me. Until the client actually tried to use the WinMo app and found out the device only had a 2 hour battery life with the background task turned on. I ultimately found another way of accomplishing my objective, but the task ended up running on the server.