react-native-share-menu icon indicating copy to clipboard operation
react-native-share-menu copied to clipboard

How can disable share View iOS

Open IbrahimCanKALYA opened this issue 3 years ago • 5 comments

I'm using this lib for receive sharing intent. I don't need custom or default share view on iOS how can i disable share View entirely?

Thanks in advance

IbrahimCanKALYA avatar Nov 15 '21 15:11 IbrahimCanKALYA

Did you figure out how to do it? I tried meddling with ShareViewController, and was able to remove share view, but the app from which I was sharing kept freezing

Tauka avatar Feb 02 '22 19:02 Tauka

I was able to do it

  1. I changed SLComposeServiceViewController to UIViewController in ShareViewController.swift
  2. Remove isContentValid, didSelectPost, configurationItems functions, and call handlePost in viewDidLoad
  3. Add viewDidAppear with completeRequest, this ensures app from which we share won't freeze
override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    
    completeRequest()
}
  1. In Info.plist of your Share Extension, change NSExtensionMainStoryboard to NSExtensionPrincipalClass, and set value to $(PRODUCT_MODULE_NAME).ShareViewController. Also you can remove MainInterface if you want

Tauka avatar Feb 04 '22 03:02 Tauka

@Tauka thanks for this! The custom view is indeed gone.

Though the original app (say Photos) still freezes with a semi transparent grey overlay on top of it. Where shall I add viewDidAppear to?

I have added

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    
    completeRequest()
}

to ShareViewController.swift. Is this correct? Thanks!

xmflsct avatar May 03 '22 22:05 xmflsct

I figure out that, if I am in the page of an image and share from there, Photos app won't stuck. However if I am in the grid view, long press an image then share, this view will stuck.

xmflsct avatar May 04 '22 21:05 xmflsct

Thanks @Tauka for the solution for disabling share pop up!

Those who are having trouble to add handlePost into viewDidLoad can use it like this

    guard let items = self.extensionContext?.inputItems as? [NSExtensionItem] else {
              print("Error: \(COULD_NOT_FIND_ITEMS_ERROR)")
              return
          }
    
    handlePost(items)

h4rshil avatar Jul 29 '23 06:07 h4rshil