Comments (4)
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.
@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.
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.
@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)
- Issue HOT 5
- Sharing from browser: real iOS device receives page title, simulators receive URL HOT 2
- Video File Issue? HOT 1
- Audio and Video share empty value problem HOT 5
- not able to share image from google photos when app in background HOT 1
- Share extension opens up different instance of application HOT 4
- This no longer works HOT 10
- Error after clicking on my app icon during sharing (Expokit, Android) HOT 1
- 0.62.2 (Podspec) HOT 1
- 0.62.2 issue HOT 2
- 🔥How to clear image from bundle when app goes in background after receiving image prop HOT 1
- Working in React Native 0.62.2 (iOS) HOT 18
- What file extensions are allowed? HOT 1
- ERROR: File not found #import "React/RCTBridgeModule.h" HOT 1
- Cannot find lDoubleConversion HOT 1
- share ActionExtension not working with firebase
- expo-dev-client / EAS build integration? HOT 1
- Not getting Url when sharing image from Google to share extension ( Android)
- Cant share screenshot on ios
- Invariant Violation: "passages" has not been registered. This can happen if:
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-share-extension.