facebook / facebook/facebook-ios-sdk

Pasteboard prompt/message appearing after photo share from ShareButton

Open
#2,524 0 comments 0 reactions 0 assignees View on GitHub
bug needs-triage
Dominant language
Swift
Stars
8.1k
Forks
3.7k
PR merge metrics
No merged PRs in 30d

Description

### Checklist before submitting a bug report

- [X] I've updated to the latest released version of the SDK
- [X] I've searched for existing [GitHub issues](https://github.com/facebook/facebook-ios-sdk/issues)
- [X] I've looked for existing answers on [Stack Overflow](https://facebook.stackoverflow.com), the [Facebook Developer Community Forum](https://developers.facebook.com/community/) and the [Facebook Developers Group](https://www.facebook.com/groups/fbdevelopers)
- [X] I've read the [Code of Conduct](https://github.com/facebook/facebook-ios-sdk/blob/main/CODE_OF_CONDUCT.md)
- [X] This issue is not security related and can safely be disclosed publicly on GitHub

### Xcode version

15.4

### Facebook iOS SDK version

17.0.2

### Dependency Manager

CocoaPods

### SDK Framework

Share

### Goals

I would like to share a photo from my app to Facebook using a ShareButton.

### Expected results

When the share is complete and my app is reactivated, the user should not be pestered with a prompt to allow/disallow pasting from Facebook.

### Actual results

The user is pestered with a prompt to allow/disallow pasting from Facebook.

### Steps to reproduce

1. Add a ShareButton.
2. Set the ShareButton's ShareContent to a SharePhotoContent with Photos[] containing one SharePhoto.
3. Tap on the 'Share' button to launch the share dialog (FB app installed on device)
4. Cancel or complete the photo share
5. User gets prompt: "MyApp" would like to paste from "Facebook"--"Do you want to allow this?"

### Code samples & details

This is similar in the unwanted behavior reported in #1467 and #1603, which were deemed to be caused by the app accessing the pasteboard and not caused by FBSDK. I have high confidence that this is not the case here. I thoroughly analyzed my app (and its dependencies) for any unintentional pasteboard access. I found the FBSDK to be the only dependency accessing the pasteboard.

Investigating the FBSDK code, I found this:

https://github.com/facebook/facebook-ios-sdk/blob/adf47300b3de4519674956cbe9d70b689432067f/FBSDKCoreKit/FBSDKCoreKit/Internal/BridgeAPI/ProtocolVersions/_BridgeAPIProtocolNativeV1.swift#L269-287

My Swift isn't very good, but it looks to me like this function accesses the pasteboard on app activation. This can cause the prompt/alert on iOS 16+, right?

WORKAROUND: I tried pre-emptively clearing the pasteboard for pasteboard type "com.facebook.Facebook.FBAppBridgeType" on app activation (based on https://github.com/facebook/facebook-ios-sdk/blob/adf47300b3de4519674956cbe9d70b689432067f/FBSDKCoreKit/FBSDKCoreKit/Internal/BridgeAPI/ProtocolVersions/_BridgeAPIProtocolNativeV1.swift#L54) and found that the paste prompt no longer appears. This seems like strong evidence that the FBSDK is causing the unneeded paste alerts.

Sample workaround code (forgive me for the Xamarin):

```
public override void OnActivated(UIApplication uiApplication)
{
UIPasteboard.General.SetData(new NSData(), "com.facebook.Facebook.FBAppBridgeType");
base.OnActivated(uiApplication);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.