Is there any delegate for monitoring progress when transfering data from WatchOs to iOs using WatchConnectivity?

383 Views Asked by At

I'm using WatchConnectivity to transfer files from Apple Watch to iOS device (this direction). Transfer itself is ok. I send file from Apple Watch by calling transfer file function:

session?.transferFile(url, metadata: metadata)

and I'm able to save a file on iOS device. But I would like to show progress of transfer to the users on iOS device. For example user tap button "Download file" on iPhone and I would like to show some UI progress bar. Is this possible? Because I found only this delegate which is called when transfer is done:

func session(_ session: WCSession, didReceive file: WCSessionFile) {

}
1

There are 1 best solutions below

0
Kjuly On

The WCSessionFileTransfer instance returned by

session?.transferFile(url, metadata: metadata)

has a NSProgress *progress property, you can use it to monitor the progress at Watch App w/ a NSTimer instance, and send live message (WCSession-sendMessage:...) to iPhone App to update related UI elements.


Note:

The progress is only available since iOS 12.0 & WatchOS 5.0.

API_AVAILABLE(ios(12.0), watchos(5.0))