Skip to content
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

A popup is shown when I try to share image but disappears before I click the Post button #13

Closed
benedict1986 opened this issue Jun 27, 2022 · 6 comments

Comments

@benedict1986
Copy link

benedict1986 commented Jun 27, 2022

Hi, @JoshJuncker ,

Thank you for building such great plugin.

I am trying to use the plugin but having an issue. I can build my application successfully and when I select an image and click the Share button, I can also select my application. When I click the Share button, a popup is shown with the image I selected.

However, before I click the Post button on the popup, my application is opened and I cannot click the Post button in the popup anymore. At a result, my application does not receive any image.

Can you please help to give some advice what could be wrong?

I also try to run your example, but get an error saying

 /Users/Admin/Desktop/Admn/share_handler-main/share_handler/example/i
    os/Share Extension/ShareViewController.swift:6:8: error: no such
    module 'share_handler_ios_models'
    import share_handler_ios_models
           ^

To run the example, I made a bit change to release the restriction of dart version since I am using

Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (6 months ago) • 2021-12-16 08:37:33
-0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1

Thank you

@JoshJuncker
Copy link
Collaborator

@benedict1986 For iOS, the plugin is supposed to skip the native share popup sheet, and immediately redirect to your app. This is because the share sheet has to be swift only code/ui, so it just redirect to the app after storing the attachments, and then the app looks up the stored attachments when it launches. It may be that your phone is going a bit slow, and the default iOS share sheet is opening up with the image before it redirects to the app.

Running the example, when you share a website (url), or text, or an image, does it show that url/text/ image file path in the example app when you share to it?

@ben-the-developer
Copy link

Hi @JoshJuncker, I went through the instruction again and found that I missed one step. Seems like it is expected that the popup will show and disappear immediately. Now I can get the image path. I haven't tried the url or text since it's not required in my app.

In terms of the example, I still get the error

/Users/Admin/Desktop/Admn/share_handler-main/share_handler/example/i
    os/Share Extension/ShareViewController.swift:6:8: error: no such
    module 'share_handler_ios_models'
    import share_handler_ios_models

@JoshJuncker
Copy link
Collaborator

JoshJuncker commented Jun 30, 2022

@ben-the-developer Make sure to follow step 6 in the readme to modify <project_root>/iOS/Podfile like below and run pod install. If you clone the repository, and open share_handler/share_handler/example, that example project should have the below code in it and working. I just tested on my machine and it seems to be working fine. But there could be some issue between our environments.

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))

  # share_handler addition start
  target 'ShareExtension' do
    inherit! :search_paths
    pod "share_handler_ios_models", :path => ".symlinks/plugins/share_handler_ios/ios/Models"
  end
  # share_handler addition end
end

@benPesso
Copy link

@ben-the-developer Make sure to follow step 6 in the readme to modify <project_root>/iOS/Podfile like below and run pod install. If you clone the repository, and open share_handler/share_handler/example, that example project should have the below code in it and working. I just tested on my machine and it seems to be working fine. But there could be some issue between our environments.

@JoshJuncker Not related to the issue above, but since you brought it up here, I thought I'll add to the discussion here...
What's the reason that this has to be manually added to the Podfile? Isn't it possible to add this automatically? (Like Firebase and other packages do, for example.)

@JoshJuncker
Copy link
Collaborator

@benPesso The reason is because the Share Extension is a different target. Flutter projects have the main target of 'Runner', and the share_handler_ios pod is automatically added to that. But Share Extensions don't include the main project dependencies by default. It's almost like a completely separate project. If there is a way to somehow remove that manual step, I would be more than happy to implement it. I just don't know how as of yet...

@benPesso
Copy link

Oh, yeah. Right. Totally glossed over the fact that it's on a separate target, unlike Firebase.

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

No branches or pull requests

4 participants