react-native-watch-connectivity icon indicating copy to clipboard operation
react-native-watch-connectivity copied to clipboard

Unimplemented delegate callback didReceiveFile

Open mdescalzo opened this issue 2 years ago • 7 comments

  • (void)session:(WCSession *)session didReceiveFile:(WCSessionFile *)file { // TODO }

mdescalzo avatar Jun 10 '22 00:06 mdescalzo

Is there a plan to implement this function? It is useful in cases where the size of the data transmitted from watch to phone is too large for sendMessage or userInfo.

mdescalzo avatar Jun 27 '22 15:06 mdescalzo

@mdescalzo do you know what the max file size is when sending data over user-info from the watch to the phone?

walterholohan avatar Jun 27 '22 19:06 walterholohan

I've seen 55k stated on stackoverflow. Our testing shows it isn't quite that straightforward. Compression appears to be applied to the object in transmission so it a function of the compressibility as well as size. When we built objects by repeatedly duplicating content, we could get some large objects over...200k-300k if memory serves. However, when we build test objects with randomized content we ran into errors in the 60k-70k range.

mdescalzo avatar Jun 27 '22 19:06 mdescalzo

@mdescalzo yes we are seeing something similar, on Apple Watch Series 3 we are seeing the error Payload too large but on series 4 it's ok.

Our plan is to save the large chunk of data to a JSON file on the apple watch, then compress it and send it back to the app using file transfer. Have you done something similar?

walterholohan avatar Jul 12 '22 09:07 walterholohan

We'd planned on something like that, but the above put a damper on that. Instead we stringified the JSON blob, broke it into pieces, sent them over transferUserInfo and reassembled them on the other side. Getting the kinks worked out was a pain, but its working so far. I think sendFile would have been a better course.

mdescalzo avatar Jul 12 '22 14:07 mdescalzo

@mdescalzo I have just created a PR that will enable you to receive a file from the watch - https://github.com/mtford90/react-native-watch-connectivity/pull/105

walterholohan avatar Jul 12 '22 20:07 walterholohan

Excellent news! I'm on another task at the moment. I'll circle back to the transmission problem when I'm done.

mdescalzo avatar Jul 13 '22 15:07 mdescalzo