vipal
vipal

Reputation: 1

is there any way to Send HTTP Requests in Background Mode (iOS) Periodically?

Hello I am developing the Application in which i need to send Data in Http request every 10 seconds. it's working fine when app is in running state but it will stop as soon as it will goes in background or inactive state.

Upvotes: 0

Views: 144

Answers (1)

user9106403
user9106403

Reputation:

Your app need to support a couple of things. If your app can have the background-running capability then you can do a couple of things.

To run periodically you will need a Timer (NSTimer). You will need a method which will execute the HTTP request.

Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(callWebservice), userInfo: nil, repeats: true)

func callWebservice() {
  // Handle response 
}

Also please refer : https://developer.apple.com/library/archive/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html

Upvotes: 1

Related Questions