Closed simonnickel closed 2 years ago
Log output of failing requests.
MatomoTracker [W] Failed dispatching events with error Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo={NSUnderlyingError=0x600001f89350 {Error Domain=kCFErrorDomainCFNetwork Code=-1001 "(null)" UserInfo={_kCFStreamErrorCodeKey=-2102, _kCFStreamErrorDomainKey=4}}, NSErrorFailingURLStringKey=<...>, NSErrorFailingURLKey=<...>, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2102, NSLocalizedDescription=The request timed out.}
Follow up on https://github.com/matomo-org/matomo-sdk-ios/issues/139
Instead of using URLSession.shared in URLSessionDispatcher a session configured for background should be used. This allows triggering the upload from the AppDelegates applicationDidEnterBackground().
Might need some more changes to URLSessionDispatcher. Seems like delegate methods need to be implemented to handle responses of background tasks. As well as handling of failing background tasks.
See https://developer.apple.com/documentation/foundation/urlsessionconfiguration/1407496-background Or some example implementation: https://www.raywenderlich.com/3244963-urlsession-tutorial-getting-started