KasemJaffer / receive_sharing_intent

A Flutter plugin that enables flutter apps to receive sharing photos, text and url from other apps.
Apache License 2.0
334 stars 395 forks source link

[iOS] Sharing a URL from Safari doesn't work #275

Closed chenfisher closed 9 months ago

chenfisher commented 9 months ago

Using version 1.6.6

App opens as expected getMediaStream emits events but the value (List<SharedMediaFile>) is always empty.

After some debugging, I've found the culprit in RSIShareViewController, viewDidAppear: https://github.com/KasemJaffer/receive_sharing_intent/blob/a0f4d8ea8008fcb62687441904c25481d8883375/ios/Classes/RSIShareViewController.swift#L56

case .text, .url:
    if let text = data as? String {
        this.handleMedia(forLiteral: text,
                         type: type,
                         index: index,
                         content: content)
    }

When data is a URL, text = data as? String will evaluate to nil, resulting in empty lists when emitting events.

One possible solution is to have a separate case for .url and use handleMedia:forLiteral with url.absoluteString But since I haven't deep dive into the rest of the package code, I'm not sure this covers everything.

@KasemJaffer what do you think?

chenfisher commented 9 months ago

Version 1.6.7 seems to have resolved this issue.