We're having a fairly strange issue with the share sheet copy activity.
We just have a short blurb about the content and then we provide the link to the share activity, as in...
guard let viewController = vc, let sourceView = viewController.view, let url = URL(string: link) else {
return
}
let activityViewController = UIActivityViewController(activityItems: [text, url], applicationActivities: nil)
viewController.present(activityViewController, animated: true, completion: nil)
activityViewController.popoverPresentationController?.sourceView = sourceView
This works perfectly fine except in our internal chat. In our chat textview, the text blurb comes through, but the link does not appear next to the text as expected.
The textview in question is a SlackTextViewController (I am aware that this is now deprecated, we've been using it for a while). I wasn't able to find any documentation that suggests they're sanitizing the input or stripping out the link in any way, but it most likely has something to do with that component. I tried a bare implementation of textView:shouldChangeTextInRange
to print the text received by the textView, and sure enough, no link is present there.
Just for completeness sake, this is what that looks like.
override func textView(_: UITextView, shouldChangeTextIn _: NSRange, replacementText text: String) -> Bool {
print(text)
return true
}
Also, if you copy/paste a link directly, that works fine. If you copy the share text as plain text and paste it, it also works fine. This leads me to believe there's something missing here in handling that share text.
Has anyone experienced this issue in the paste? Is there some lifecycle/delegate that needs to be implemented to handle the shared text?
Hopefully, this helps someone else - The issue here is slacktextviewcontroller overrides the default paste behavior, and this causes some issue with the share copy where it pastes the text, but not the copied URL.