react-native-share / react-native-share

Social share, sending simple data to other apps.

Home Page:https://react-native-share.github.io/react-native-share

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`saveToFiles` ignores `failOnCancel: false` and throws an error [iOS]

Raigen opened this issue · comments

Steps to reproduce

  1. Use the share remote example from the docs to download a file and share it.
  2. Set saveToFiles: true to immediately get a document picker and failOnCancel: false to not fail when the user cancels.
  3. Cancel the file sharing (pressing pack and cancel or swiping the overlay down) => An error appears in the console and the code fails.

Expected behavior

I do not want to get an error when I set failOnCancel: false

Actual behavior

When using saveToFiles: true and failOnCancel: false I still get an [Error: CANCELLED] when I cancel or swipe down the share overlay on iOS.

Environment

  • React Native version: 0.73.4
  • React Native platform + platform version: iOS 17.4
  • Typescript version: 5.2.2

react-native-share

Version: 10.1.0

I have no experience with native code but still looked into the code a bit to at least understand the issue. failOnCancel is handled in the typescript part of the code depending on the result, and the error is a different one if it was active.
The native code for saveToFiles looks like a cancel is not handled at all and the error is originally from here.
https://github.com/react-native-share/react-native-share/blob/main/ios/RNShare.mm#L260-L282