Posts

Post marked as solved
3 Replies
0 Views
Dear Eskimo I have succeeded to get the information by setting URLSession delegate. By the way, the reason I failed before is the delegate declaration in my program had some mistake. Thank you very much!
Post marked as solved
3 Replies
0 Views
Dear Eskimo Thank for you very much! I also noticed some other issue such as this one. I tried the same method with delegate, but I got the same result mentioned in the issue that I couldn't get any reponse or error information from "Delegate method urlSession(_:dataTask:didReceive:)". It seems you have given some help for the issue above. Could you please give me more detail advice?
Post marked as solved
9 Replies
0 Views
Dear Eskimo Thanks for your reply very much! Are you using a UIApplication background task to keep your app running while the request is in flight? The "UIApplication background task" you wrote above meant the API such as "UIApplication.shared.beginBackgroundTask()"? My program is shown in following: let config:URLSessionConfiguration = URLSessionConfiguration.background(withIdentifier: "abcd") self.session = URLSession(configuration: config, delegate: nil, delegateQueue: nil) let task: URLSessionDataTask = session!.dataTask(with: myRequest as URLRequest) task.resume() Hope to continue to get your help!
Post marked as solved
9 Replies
0 Views
Dear Eskimo Thanks a lot! As I introduced at the beginning, my program receives the Beacon's signal every second as a trigger to call Corelocation's handler, in which the URLSession (dataTask) is used to forward data received from Beacon to sever. And for each communication with server, only several bytes data ( small amount of data) is sent to server. The prcessing from receiving the Beacon's signal to Call Corelocation's handler seems no problem and can be kept foever in background. And my problem is that URLSession (dataTask) is usually stopped and restarted suddenly in background, although only small amount of data is sent each time, which is send periodly and not sent without intervals.  That mechanism will give you background execution time to run your networking. Or maybe it won’t. You means is sometimes my program(URLSession communication) can not be excuted for some reason(some mechanism in iOS)? Best Regards
Post marked as solved
9 Replies
0 Views
Dear Eskimo Thank you very much! About the key point you mentioned above, you suggested me to use a standard session to upload a small amounts of data. But Instead of sending data only once, my system is hoped to send data in the background periodically and contineously. Do you think my system can work well without background session or using the hybrid approach? Best Regard
Post not yet marked as solved
1 Replies
0 Views
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
Post marked as solved
9 Replies
0 Views
Dear Eskimo Thanks for your reply very much! I get a lot of very important informations from your reply as following: Even if you use a background task to continue long transfers, it's still important that your app support resumable transfers. There are numerous situations where this might be useful: if it's running on a device that doesn't support multitasking if the network connection is interrupted during the transfer if your app asks to start a background task and the system refuses to do so (that is, if -[UIApplication beginBackgroundTaskWithExpirationHandler:] returns UIBackgroundTaskInvalid) if system resources get low and thus the system must suspend or terminate your app before its background tasks are complete if the transfer takes more time than the background task will allow Return back to my question, according to the information above, can I think the URLSession can not be kept for ever because of some reasons such as "if your app asks to start a background task and the system refuses to do so", or "if system resources get low and thus the system must suspend or terminate your app before its background tasks are complete" and so on ? Could you please tell me why "the system refuses to do so" ? What is the detail conditions of "if system resources get low" , which means low battery, low memory or some other reason? In my experiment, the URLSession communication will be stopped suddenly and restarted suddenly, could you please tell me how long the URLSession communication will take from stop to start normally? Best Regards,