I'm using Watch Connectivity to transfer files from the Watch to its paired iOS device. File transfer is successful in my first tests, but obviously I need to erase the source file when it is - successfully - sent.
When should I do that?
- just after initiating the file transfer, using
transferFile(file: NSURL, metadata: [String : AnyObject])
when getting the returnedWCSessionFileTransfer
? - when getting the callback
func session(_ session: WCSession, didFinish fileTransfer: WCSessionFileTransfer
? --> but will the callback always be called, even if the transfer finishes while the app is in background? - some other time?
NB: I'd really want to avoid implementing a custom 'ack' system, thus not using any user info/application context transfer.
Hi there!
If you delete the source file just after you initiate the transfer, then you'll lose all of the files from the Watch that don't transfer successfully.
Your best option is to delete the file when you get the callback that the file transfer completed. If the transfer was successful, you should be able to delete the file at that time.