Closed wehriam closed 3 years ago
@wehriam thanks for that. if you need to adjust the header search paths, I think you can do this by editing the podspec. this might work, but I've not tested it:
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/../../node_modules/react-native-background-upload/ios\"" }
possible that it is USER_HEADER_SEARCH_PATHS
Notes
Merges the current master branch with PR #145 from @drash-course and recreates the
NSURLSession
after eachURLSessionDidFinishEventsForBackgroundURLSession
call. All notes below the line are from @drash-course #145.Problem
Currently, the uploads tasks initiated by the app while in foreground continue to completion even if the app is backgrounded. Unfortunately, the app does not wake up to receive the
URLSession:task:didCompleteWithError
event until it is brought to foreground by the user. This means the app does not receive any events (e.g. "completed") until then.What this PR does
This PR adds a
setBackgroundSessionCompletionHandler
setter in the library to let the AppDelegate set the background session completion handler when it receives theapplication:handleEventsForBackgroundURLSession:completionHandler
event. The lib will then wait for a short time to let the JS side provide new tasks (if any) and call the handler to sleep again.Here is a sample implementation for the AppDelegate:
There should be no regression if the AppDelegate does not implement this. Most apps don't create more tasks after completion so they won't need this addition.
Feel free to amend this PR or discuss the changes.
Install steps
$(SRCROOT)/../node_modules/react-native-background-upload/ios
must be added to the header search paths to enable the AppDelegate to find "VydiaRNFileUploader.h". Do you know how to automate this withreact-native link
?