ShoutSocial / share_handler

A plugin to facilitate receiving and handling share intents
42 stars 39 forks source link

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

Closed benedict1986 closed 1 year ago

benedict1986 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

@ben-the-developer Make sure to follow step 6 in the readme to modify /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 commented 2 years ago

@ben-the-developer Make sure to follow step 6 in the readme to modify /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 commented 2 years ago

@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 commented 2 years ago

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