Skip to content

Share.share copies message and url as a single pasteboard item on iOS - #59653

Draft
janicduplessis wants to merge 1 commit into
react:mainfrom
janicduplessis:@janic/share-single-pasteboard-item
Draft

janicduplessis wants to merge 1 commit into
react:mainfrom
janicduplessis:@janic/share-single-pasteboard-item

Conversation

@janicduplessis

Copy link
Copy Markdown
Contributor

Summary:

When Share.share({ message, url }) (or ActionSheetIOS.showShareActionSheetWithOptions) is called with both message and url on iOS, RCTActionSheetManager passes the message and the NSURL to UIActivityViewController as two activity items. Tapping Copy writes them as two separate pasteboard items. A plain-text paste only reads the first one, so the URL is lost. That includes pasting on a Mac through Universal Clipboard.

This PR wraps both in UIActivityItemSource objects, but only when both message and a non-data: url are set:

  • the message source returns nil for Copy and the message for every other activity;
  • the URL source returns "<message> <url>" for Copy and the NSURL for every other activity.

Other activities get the same items as before. The share sheet still builds its own link preview, because the URL source's placeholder is the NSURL. When subject is set, both sources return it from the public subjectForActivityType: method. When it isn't set, behavior is the same as today. Message-only, url-only and data: shares are unchanged.

This is the same report as #29425. That issue was closed after the cause was attributed to malformed URLs, but the URL there was valid.

Changelog:

[IOS] [FIXED] - Share.share copies message and url as a single pasteboard item

Test Plan:

RN Tester → APIs → Share → "Share message, URL (iOS) and title (Android)", on an iPhone 18 Pro simulator (iOS 27.0). I tapped Copy and logged UIPasteboard.generalPasteboard in the completion handler, using a temporary log that isn't in this PR:

numberOfItems xcrun simctl pbpaste
Before 2 message only, no URL
After 1 <message> https://reactnative.dev/blog/2020/07/17/react-native-principles
  • The share sheet's link preview (title, domain, site icon) is the same before and after.
  • On a physical iPhone (iOS 27 beta), I tested the same item-source setup as an app-level native module. The header matched plain Share.share side by side, and Copy pasted on a Mac through Universal Clipboard included the URL.
  • Not covered: the Mail subject, because the Simulator has no Mail app.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 29, 2026
@facebook-github-tools facebook-github-tools Bot added the Contributor A React Native contributor. label Oct 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant