szimek / sharedrop

Easy P2P file transfer powered by WebRTC - inspired by Apple AirDrop
https://www.sharedrop.io
MIT License
9.99k stars 729 forks source link

[Feature Request] iOS support #57

Closed frol closed 4 years ago

frol commented 7 years ago

Is it possible to implement ShareDrop for iOS (iPhone / iPad)? I would love to use ShareDrop exclusively for all the devices...

szimek commented 7 years ago

Not at the moment, because Safari on iOS doesn't support WebRTC data channels. The new Safari in iOS 11 does support some parts of WebRTC, but AFAIK it still doesn't support data channels. However, there was a very similar project (can't remember its name though :/), which used websockets and an intermediary server in such cases. It wasn't P2P then though, but still worked pretty well.

frol commented 7 years ago

I have iOS 11 on my iPhone and neither Safari nor Google Chrome can send or receive files, though the device is discoverable. That is unfortunate... ShareDrop is an awesome project! Thank you!

szimek commented 7 years ago

I haven't tried iOS 11 yet, but it looks like at least discovery works fine ;) Hopefully, they'll add data channels support in the future as well and everything will "just work". Cheers!

frol commented 7 years ago

Well, I went ahead and extracted the console logs from iOS 11 (using MIHTool):

1f7f9e4e-9bb1-4552-9eee-71b61dc01a77

Nothing happens after that, neither errors, nor any further progress.

Also, I checked other WebRTC services and discovered that https://webtorrent.io/ (to be more accurate, https://instant.io/) supposedly uses WebRTC with data channels and it works fine on my iOS devices.

szimek commented 7 years ago

@frol Thanks for checking it out! ShareDrop at the moment uses a pretty old library (PeerJS) for handling WebRTC related stuff (it worked so far, so there was no reason to change it) and I wanted to switch to simple-peer (which is used by WebTorrent) or even WebTorrent itself ;) I know that at least at the beginning, Safari on iOS 11 did not support data channels. If more recent versions do actually support it, then it's really awesome and I will try to update ShareDrop as soon as I get my hands on a new iPhone (I still got iPhone 5) and iOS 11. Maybe it can even work in Edge ;)

frol commented 7 years ago

I can help you with debugging if you wish. I only need some guidance (I am familiar with JS ES6).

szimek commented 7 years ago

Thanks! I haven't really touched this code much since ages, so I'd have to clean it up a bit and switch to simple-peer, which is actively maintained and hopefully might just fix these issues. I'll get back to you if I have any updates.

frol commented 5 years ago

FYI, snapdrop can send and receive files on iOS 12 (I cannot check on iOS 11), though receive process fails to save the received blob.

bertrandrussell commented 5 years ago

Hey guys, any update on the above? We're trying to use Snapdrop for sending a small video to an iPhone, so curious if you guys have resolved the issue.

szimek commented 5 years ago

It looks like both desktop and mobile Safari do finally support WebRTC data channels that are required by ShareDrop to work. There are 2 issues though:

szimek commented 5 years ago

Small update - desktop Safari is now supported! iOS is still not though, because it seems I'd have to ask for mic and camera access to be able to transfer files using p2p (SnapDrop uses websockets as a fallback, that's why it works there) and it's going to be rather hard to explain to users that I need this access just to transfer a file :/ I did some tests and if I do ask for it and grant it, it work fine though.

However, receiving files on iOS is also a bit awkward, as it tries to open the received file in the same tab as the running app, instead of showing some kind of download dialog :/ I guess it's the same issue as mentioned above: https://github.com/RobinLinus/snapdrop/issues/59.

BTW. Snapdrop looks really cool ;)

szimek commented 4 years ago

I'm closing this issue, because, surprisingly, it now works in iOS as well.