Skip to content

fix(share_plus): Present Share Sheet on the top ViewController #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

rayliverified
Copy link
Contributor

Description

Update iOS share target to present on the top ViewController. This fixes "Unable to present" errors when the app is already presenting such as in an add to app scenario.

Related Issues

#251

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
    No tests need to be updated.
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
    No doc changes needed.
  • The analyzer (flutter analyze) does not report any problems on my PR.
    warning - The path F:\Development\FlutterPlusPlugins\packages\share_plus is not posix - example\pubspec.yaml:9:11 - path_not_posix
  • I read and followed the Flutter Style Guide.
  • I am willing to follow-up on review comments in a timely manner.

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 a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@miquelbeltran
Copy link
Member

Thanks @searchy2 ! Can you update also the pubspec.yaml and bump the version number to 2.1.3?

@rayliverified
Copy link
Contributor Author

Bumped!

@miquelbeltran
Copy link
Member

I tested this and seems to work, however CI is complaining with the following error:

These files are not formatted correctly:


-----------------------------------------------------------------
packages/share_plus/ios/Classes/FLTSharePlusPlugin.m
-----------------------------------------------------------------

diff --git a/packages/share_plus/ios/Classes/FLTSharePlusPlugin.m b/packages/share_plus/ios/Classes/FLTSharePlusPlugin.m
index accd0e7..1caf92d 100644
--- a/packages/share_plus/ios/Classes/FLTSharePlusPlugin.m
+++ b/packages/share_plus/ios/Classes/FLTSharePlusPlugin.m
@@ -154 +154 @@ static UIViewController *TopViewControllerForViewController(UIViewController *vi
-        TopViewControllerForViewController(RootViewController());
+          TopViewControllerForViewController(RootViewController());
@@ -183 +183 @@ static UIViewController *TopViewControllerForViewController(UIViewController *vi
-        TopViewControllerForViewController(RootViewController());
+          TopViewControllerForViewController(RootViewController());

-----------------------------------------------------------------

Could you solve this formatting issue? then I will merge and release.

@rayliverified
Copy link
Contributor Author

rayliverified commented May 31, 2021

I'll probably need your help with the formatting.
Trying to run the format command melos run format outputs this error;

F:\Development\FlutterPlusPlugins>flutter pub global run flutter_plugin_tools fo
rmat
Unhandled exception:
Invalid argument(s): join(null, "gcloud-service-key.json"): part 0 was null, but
 part 1 was not.
#0      _validateArgList (package:path/src/context.dart:1102:5)
#1      Context.join (package:path/src/context.dart:242:5)
#2      join (package:path/path.dart:265:13)
#3      new FirebaseTestLabCommand (package:flutter_plugin_tools/src/firebase_te
st_lab_command.dart:33:13)
#4      main (package:flutter_plugin_tools/src/main.dart:54:18)
#5      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isola
te_patch.dart:281:32)
#6      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dar
t:184:12)
pub finished with exit code 255

Any idea what's wrong?

Also, does the format tool format iOS code?

@rayliverified
Copy link
Contributor Author

@miquelbeltran Can you help me fix the formatting?

@mhadaily
Copy link
Member

mhadaily commented Jun 7, 2021

can you also please merge with main, we have fixed a few things for CD/CI

- Present share sheet on the currently visible view controller.
@rayliverified rayliverified force-pushed the share_ios_present_fix branch from cc5790b to 1dafbb2 Compare June 7, 2021 16:06
@rayliverified
Copy link
Contributor Author

Done!

@mhadaily
Copy link
Member

mhadaily commented Jun 7, 2021

Perfect, now it seems we have a formatting issue, could you run melos run format on your machine and commit the changes too? @searchy2 THANK YOU

@rayliverified
Copy link
Contributor Author

That didn't work and threw an exception. I'll need you to run it for me.

@mhadaily
Copy link
Member

mhadaily commented Jun 7, 2021

What's the exception?

if you want me to run it for you, you need to give me access to https://github.com/searchy2/plus_plugins/tree/share_ios_present_fix

@rayliverified
Copy link
Contributor Author

I'm running into the same issue as before:

F:\Development\FlutterPlusPlugins>flutter pub global run flutter_plugin_tools fo
rmat
Unhandled exception:
Invalid argument(s): join(null, "gcloud-service-key.json"): part 0 was null, but
 part 1 was not.
#0      _validateArgList (package:path/src/context.dart:1102:5)
#1      Context.join (package:path/src/context.dart:242:5)
#2      join (package:path/path.dart:265:13)
#3      new FirebaseTestLabCommand (package:flutter_plugin_tools/src/firebase_te
st_lab_command.dart:33:13)
#4      main (package:flutter_plugin_tools/src/main.dart:54:18)
#5      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isola
te_patch.dart:281:32)
#6      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dar
t:184:12)
pub finished with exit code 255

I've invited you to the repo, thank you for your help here!

@miquelbeltran
Copy link
Member

@searchy2 can you enable “Allow edits by maintainers”? I just checked out your PR and there were still unmerged changes from main.

@rayliverified
Copy link
Contributor Author

It's checked, just updated from main again.

@miquelbeltran
Copy link
Member

Can you run melos run format?

@miquelbeltran
Copy link
Member

going to unblock this, may need to create a new PR

@miquelbeltran
Copy link
Member

continuing in #307

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 6, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants