I am developing an app where I have to upload an entity with its relation. (I think this is similar to dropbox files uploading) This entity is called PlaceEntity
and has a relation with PictureEntity (to many)
. I want to do it using NSURLSession
to handle the upload while the app is suspended. So, what I am doing is I create the uploadTasks
for place pictures, and I start them. After each picture upload I have to receive data and save some information in the pictureEntity
. When all the pictures are uploaded I create a new task and I save the place in the server.
I have tested it in background and foreground
and everything works fine. The problem is when I suspend the app. The upload picture requests are executed(I know because I watch the request with Charles MAC OS app) the problem happens when I have to update the information in core data
, after each upload. The method:
- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data
never is called because my app is completely out. I can't then update Core Data or launch a new request.
Any idea??
Thank you