views:

68

answers:

3

Hi, everyone,

I want to ask a question about the iPhone application. I am writing a program which can upload some information to a server. However, the user has to click a button before the upload. Therefore, is it possible for the application to upload the data to server regularly after the user only click one time of the button?

It means that the app will upload the data at 12:00 p.m, 12:00 am .... Thank you.

+2  A: 

Please correct me if I'm wrong, but I do not believe this is possible using the current official SDK.

Justin
+3  A: 

It is possible if and only if your app run all the time. Otherwise, if users quit your app then you cannot set and run any code inside your app. You also cannot set any timer inside iphone to run your app.

So, if the user open your app in the time. Then you can use NSTimer to schedule the time to upload your data. If user quit, you stored the last time you upload data, then when user open your app again, you check for the last time uploading and if it is too old, you upload data again. + (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds invocation:(NSInvocation *)invocation repeats:(BOOL)repeats

More here

vodkhang
+1 for answering the question behind the question.
Justin
+1  A: 

I dont know why you need to send the data to webserver regularly.

Suppose if you are not running the application for 7 days, the data is not gonna change in iPhone den whats the reason to re upload the unchanged data.

So suggest you to upload at the time of exiting the application or at the time of starting the application What ever you prefers.

Happy Coding...

Suriya
Of course the data changes if the phone is moving...it's tracking the phone.
Will Hartung
Data wont change even if the iPhone is moving if your application is not open.If your application is closed theres no way that your data is gonna change. So i stick to my suggestion that upload while you start the application and put the timer for the specific interval to upload the data.
Suriya