How to keep the communication between iphone and server in background

I want to send the data from iphone to server periodly in background.

I use URLSession (dataTask) to try it , and when my program is changed into background:

  • sometimes, the communication can be kept for several hours without any problem
  • sometimes, the dataTask will be stopped and after several minutes, it will be restarted automatically

Is there any method to keep the communication between the iphone and server continuously?

I responded on your other thread.

Dear Eskimo

Thank you very much!

This question is really same with the other one, I am sorry to submit two similar questions.

At first, I submitted the other one to explain the whole system. But I am afraid that the whole system maybe make people confused, so I pick up the most part that I want to ask (URLSession communication) and submit it here.

I think I should close this topic and hope to get your help in the other one continuously.

Best regards

How to keep the communication between iphone and server in background
 
 
Q