ShoutSocial / share_handler

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

Hide the default share modal #49

Closed kaciula closed 11 months ago

kaciula commented 1 year ago

Is there a way to not show the default share modal while the share is going to the Flutter app?

Can we at least modify it so it's something transparent or something that does not stand out?

"Note that for a brief moment, a default share modal might show up before it redirects to the app (particularly noticeable when using a simulator)"

firstmetcs commented 11 months ago

+1 @JoshJuncker

JoshJuncker commented 11 months ago

@kaciula There might be a way. I'm not sure. So far the ux has been good enough for the apps I have used it on. I'm happy to look at a pr if you figure something out though.

kaciula commented 11 months ago

Unfortunately I come from the Android side so I am not very familiar with iOS code.

firstmetcs commented 11 months ago

@kaciula There might be a way. I'm not sure. So far the ux has been good enough for the apps I have used it on. I'm happy to look at a pr if you figure something out though.

It seems that you can put the code belows in the isContentValid() method, the share extension will go to our app immediately with out the default share modal


        Task {
            await handleInputItems()
        }

finally it looks like

...
    public override func isContentValid() -> Bool {
        Task {
            await handleInputItems()
        }
        return true
    }
...

works perfectly for me with local debug env

FYI @JoshJuncker

firstmetcs commented 11 months ago

reference with https://juejin.cn/post/7236021829000101947 later I will try to commit a pull request to improve this

JoshJuncker commented 11 months ago

@firstmetcs I tried what you showed above, but it seems to call handleInputItems multiple times. So when I share an image, it comes through to the flutter app as 2 images. It also hits the deep link twice, so the flutter app gets 2 events on the ShareHandlerPlatform.instance.sharedMediaStream. However, it does seem to skip the UI, so you may be on to something there.

firstmetcs commented 11 months ago

@firstmetcs I tried what you showed above, but it seems to call handleInputItems multiple times. So when I share an image, it comes through to the flutter app as 2 images. It also hits the deep link twice, so the flutter app gets 2 events on the ShareHandlerPlatform.instance.sharedMediaStream. However, it does seem to skip the UI, so you may be on to something there.

Put the main task in isContentValid() method seems not to be a good idea, so in my pr #68 I change the super controller to UIViewController and put the main task in viewDidLoad, works perfectly for me. @JoshJuncker