Open w3ggy opened 2 years ago
After logs investigation I see:
but there is no successful message:
Looks strange like uploadTasks
is not empty but urlSessionDidFinishEvents
has been called:
I see URLSessionDidCompleteWithError
after URLSessionDidFinishEvents
2022-02-15 23:13:17.568849+0400 Runner[20204:1011071] URLSessionDidFinishEvents:
2022-02-15 23:13:17.569594+0400 Runner[20204:1010718] URLSessionDidCompleteWithError: chillisource.flutter_uploader.upload.background.25F06BE6-E4AD-4E30-AF59-BB03444803EE with response: <NSHTTPURLResponse: 0x282a91020> { URL: https://qa.app.ai/api/v1/photos/ } { Status Code: 201, Headers {
"Alt-Svc" = (
clear
);
"Content-Length" = (
219
);
"Content-Type" = (
"application/json"
);
Date = (
"Tue, 15 Feb 2022 19:13:15 GMT"
);
Server = (
nginx
);
Vary = (
Accept
);
Via = (
"1.1 google"
);
allow = (
"POST, OPTIONS"
);
"referrer-policy" = (
"same-origin",
"same-origin"
);
"x-content-type-options" = (
nosniff
);
"x-frame-options" = (
DENY
);
} } and status: 201
2022-02-15 23:13:17.569776+0400 Runner[20204:1010718] URLSessionDidCompleteWithError: upload completed
but according to pattern of the message it is the following line which is ok:
My thoughts about this problem:
When I lock the device, the system calls the urlSessionDidFinishEvents
after some time seconds but I still have uploadTasks
. Is it the desired behavior by Apple? How to make uploading all tasks in queue?
Intermediate results of my investigation:
I noticed that urlSessionDidFinishEvents
is called but uploadTasks
is not empty. It is ok according to the doc: https://developer.apple.com/documentation/foundation/nsurlsession/1411578-gettaskswithcompletionhandler
I received the following logs:
uploadTasks
are completed but not empty. Any ideas why?
@w3ggy did you find any solution for this issue ?
The case: I want to make my app uploading 500-1000 images in the background even when the device is locked. Everything works fine when the app is in the foreground.
The issue: When I lock the device, I don't receive any events neither in Flutter nor in native. Now it is impossible to debug the Flutter iOS app when the device is locked. Thus, I am trying to debug the native one.
The code for scheduling uploading on the Flutter side:
The background:
Data protection
for the app or set a specific level? I saw some problems with those settings on stackoverflow.com but not sure that it is a key