Skip to content

Conversation

StanleyCocos
Copy link
Contributor

@StanleyCocos StanleyCocos commented Sep 4, 2025

Description

This PR removes the previous standard of using the dealloc callback. Since in some cases dealloc may be delayed after sharing is completed, it has been modified to use the official API callback (activityViewController.completionWithItemsHandler), which is also the Apple recommended approach, to ensure normal return in most cases.

fix: #3631

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I titled the PR using Conventional Commits.
  • I did not modify the CHANGELOG.md nor the plugin version in pubspec.yaml files.
  • All existing and new tests are passing.
  • The analyzer (flutter analyze) does not report any problems on my PR.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate that with a ! in the title as explained in Conventional Commits).
  • No, this is not a breaking change.

@StanleyCocos
Copy link
Contributor Author

The Android test failure seems to be a separate issue and is unrelated to this PR. I have already submitted a PR to upgrade the dependencies.

@StanleyCocos StanleyCocos changed the title fix: unable to get the correct result fix(share_plus): unable to get the correct result Sep 4, 2025
@StanleyCocos StanleyCocos marked this pull request as ready for review September 4, 2025 02:03
@vbuberen vbuberen changed the title fix(share_plus): unable to get the correct result fix(share_plus): unable to get the correct result on iOS Sep 4, 2025
@vbuberen
Copy link
Collaborator

vbuberen commented Sep 4, 2025

Just ignore Android part for now, considering that your changes are for iOS.

@OutdatedGuy
Copy link
Contributor

Can confirm solves the issue of no response received on iOS 26 beta 6


Before

iOS 26:

Simulator.Screen.Recording.-.iPhone.16.Plus.-.2025-09-09.at.06.10.49.mp4

After

iOS 15.5:

Simulator.Screen.Recording.-.iPhone.13.Pro.-.2025-09-09.at.06.05.12.mp4

iOS 26:

Simulator.Screen.Recording.-.iPhone.16.Plus.-.2025-09-09.at.06.02.10.mp4

@miquelbeltran
Copy link
Member

miquelbeltran commented Sep 9, 2025

Thanks @StanleyCocos for the PR with the fix, and @OutdatedGuy for testing it.

To me, the code change seems a good simplification on the original implementation, removing this unnecessary (??) UIActivityViewSuccessCompanion. As I see, the problem is that the original UIActivityViewSuccessCompanion was not being destroyed (or the dealloc method not called) causing the awaited call to the share method to be suspended forever.

What I am not understanding is what was the UIActivityViewSuccessCompanion purpose and if this would create a new set of issues?

@StanleyCocos
Copy link
Contributor Author

What I am not understanding is what was the UIActivityViewSuccessCompanion purpose and if this would create a new set of issues?

I completely understand your concerns. At first, I was also worried that this change might affect other functionality and potentially cause new issues.

However, I believe that according to Apple’s documentation, this property is clearly explained:

When the user-selected service finishes operating on the data, or when the user dismisses the view controller, the view controller executes this completion handler to let your app know the final result of the operation.

In practice, there may be a very small number of special cases where this callback is invoked multiple times. However, I believe these special cases can be ignored for now. Alternatively, we could add a callback parameter to pass this callback to Dart to handle these special cases, but that would be another breaking change and still would not fix the issue of correct return values.

@vbuberen
Copy link
Collaborator

@miquelbeltran If you are Ok with these changes, let's put it into this breaking change release as well. Or you would like to have this change released later?

@miquelbeltran
Copy link
Member

miquelbeltran commented Sep 10, 2025

hey, yes I am fine with this, and considering how quickly ios26 adoption will be, I'd rather have this fix out.

@miquelbeltran miquelbeltran merged commit 3bd253b into fluttercommunity:main Sep 10, 2025
19 of 21 checks passed
@StanleyCocos StanleyCocos deleted the fix/share branch September 12, 2025 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: SharePlus.instance.share does not return or throw on iOS 26 beta
4 participants