Giter Site home page Giter Site logo

Comments (4)

jdrydn avatar jdrydn commented on September 2, 2024

I may not be an iOS developer, but these lines suggest this is only for URLs and not for other forms of content. Fortunately that's completely fine for me, but is there any way to trigger the RCTPromiseRejectBlock if the content being shared is not a URL?

from react-native-share-extension.

alinz avatar alinz commented on September 2, 2024

@jdrydn That is correct. My use case was only for URL. I'm up for a nice PR. 👍
if you plans to write one for iOS, would you mind write one for android as well. I want to keep the features the same for both platform.

For your question, there are couple of things we can do. The good news is value comes with type. so one option would be passing the path of the image back and you can either show it on share extension view or using network api to upload it to server. Remember, share extension must be as light as possible,

from react-native-share-extension.

jdrydn avatar jdrydn commented on September 2, 2024

Given my inexperience with Objective-C, I'm definitely not the best person to try writing "light as possible" code 😜

However you can use the extension's Info.plist to limit your extension to only receiving URLs, as this Apple developer documentation explains, like so:

<key>NSExtensionAttributes</key>
<dict>
  <key>NSExtensionActivationRule</key>
  <dict>
    <key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
    <integer>1</integer>
  </dict>
</dict>

This means it'll only show your extension for apps sharing a single URL, and other apps (like Photos) won't be able to share content with your extension. Literally, your app won't show up on the share actionsheet. Which is perfect for this codebase (because [context.inputItems firstObject]) 😄

This is definitely a short-term solution, or only applicable to apps that only want URLs?

@alinz: It could be worth adding this to the README if this was only designed for URLs?

from react-native-share-extension.

alinz avatar alinz commented on September 2, 2024

@jdrydn thanks for feedback. The thing is you can not publish your app to App Store if you don't set that one right. That's one the reason I did that. This is a limited configuration and it's not enough. What if you want to share from notes app which has some URLs? you can still grab those and process the urls in JS code.

Any changes to iOS must be reflected to Android as well. I don't want to have a specific API for android and iOS.

I'm closing this ticket but if you want you can make a PR and I would be happy to merge it.

cheers

from react-native-share-extension.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.