Comments (25)
Hello @infojunkie I commented here due to this package cannot be updating by the Author and this package is only available for image and text. I have written package is Supports file, image & text share receiving . So here i will Commented here. I have created a package from scratch @infojunkie please compare this two packages
from react-native-share-menu.
A possible hack is to load the URL you receive in a hidden WebView and get the title from inside it:
handleMessage(message) {
// message.nativeEvent.data contains the page title
console.log(message.nativeEvent.data);
}
render() {
return (
<WebView
source={{ uri: "put here the URL from the intent" }}
injectedJavaScript="window.postMessage(document.title)"
onMessage={this.handleMessage}
/>
)
}
from react-native-share-menu.
Thank a lot for your help! I can't believe Chrome doesn't provide the webpage title to the share action. Sheesh.
from react-native-share-menu.
Hmm. According to this, the title should be included by Chrome: https://paul.kinlan.me/parsing-screenshot-from-chrome-for-android-send-intent/
from react-native-share-menu.
i ve used this package react-native-receive-sharing-intent
from react-native-share-menu.
Hello @ajith-ab it looks that the package that you claim to be using is actually your own creation. Sounds like a disingenuous way to advertise for your module, by tagging every open issue here! It's also a pity you chose to create your own package from scratch, instead of contributing to an existing one.
from react-native-share-menu.
Depends on the app that is sharing the URL, if it includes extra data besides the URL or not. You can check if Intent.EXTRA_SUBJECT
is set.
from react-native-share-menu.
I'm sharing the URL from a mobile browser chrome for example. Would the webpage title be in Intent.Extra_Subject? Or do I need to parse the title and put it in extra_subject by editing the react-native-share-menu plugin?
from react-native-share-menu.
You need to modify the module anyway. You should check if the title is in Intent.EXTRA_SUBJECT
, around here: https://github.com/meedan/react-native-share-menu/blob/master/android/src/main/java/com/meedan/ShareMenuModule.java#L54, by adding a line like String title = intent.getStringExtra(Intent.EXTRA_SUBJECT);
. Then you can pass the title
variable over to the successCallback
. If it works, it would be great if you can submit a PR :)
from react-native-share-menu.
So something like this?
if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
String input = intent.getStringExtra(Intent.EXTRA_TEXT);
String title = intent.getStringExtra(Intent.EXTRA_SUBJECT);
successCallback.invoke(input, title);
from react-native-share-menu.
Yes! on the callback side, please make sure that title
is not mandatory.
from react-native-share-menu.
Any recommendations on how I would ensure it's not mandatory?
from react-native-share-menu.
I mean, just make sure that the callback still works if the title is not present.
from react-native-share-menu.
With this adaptation of the .getSharedText function, the value of "title" is undefined after share action from browser (but perhaps there's something wrong with the way I added "title: string" ?):
ShareMenu.getSharedText((text: string, title: string) => {
console.log("shared data is: " + text + " and " + title)
if (text && text.length) {
var share = { link: text, comment: title };
that.props.navigation.navigate("AndroidShareScreen", {
share: share
});
}
});
from react-native-share-menu.
Probably not set by the browser then :(
from react-native-share-menu.
Is there a way to get the title of the webpage? In javascript this is quite simple. It must be possible on Android!
from react-native-share-menu.
Ah, good idea. I'll try it.
from react-native-share-menu.
Oh, but this will create delay in the display of the webpage title. So it will be necessary to pass the URL to a view that invisibly loads the page completely to get the title, and then invisibly loads another view that displays the Title and the URL allowing the user to confirm what they wanted to share. Seems very complicated for a simple share action :(
from react-native-share-menu.
Yeah, any approach to get the title from the target app side will have a delay because you'll need to basically load the URL again... that's why in the first place I suggested to try to see if the source app provides the title already... too bad it doesn't :(
from react-native-share-menu.
You're welcome, good luck. If you find another solution please update here.
from react-native-share-menu.
Ok, so it does grab the title and the URL. I just can't get both through the callback with successCallback.invoke(input, title). Any suggestions on how to get two values through the callback?
from react-native-share-menu.
Passing an Array to the callback doesn't seem to work. Admittedly I'm not very familiar with Java...
if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
String input = intent.getStringExtra(Intent.EXTRA_TEXT);
String title = intent.getStringExtra(Intent.EXTRA_SUBJECT);
String[] values = {input, title};
successCallback.invoke(values);
from react-native-share-menu.
Reopening and labeling as "feature".
from react-native-share-menu.
Did anyone find the solution here? I need to extract the URL and Title from the browser after sharing selected text.
Thanks in advance!
from react-native-share-menu.
just put these lines
//keys
final String EXTRA_DATA_KEY = "extra"; //created new vri for extra
if (Intent.ACTION_SEND.equals(action)) {
if ("text/plain".equals(type)) {
data.putString(DATA_KEY, intent.getStringExtra(Intent.EXTRA_TEXT));
//add this line
data.putString(EXTRA_DATA_KEY,intent.getStringExtra(Intent.EXTRA_SUBJECT));
return data;
}
I hope this will be helpful for you
, connect with me on Linkedin jayesh karma
from react-native-share-menu.
Related Issues (20)
- Show more than one options (Post, Community, Activity, Event) while sharing images from gallery HOT 1
- 'openURL:options:completionHandler:' is unavailable: not available on iOS
- Crash on Android 12
- Android Manual Steps
- Share intent for multiple links crashing
- Issue While Building the app after installation HOT 2
- CustomView not opening for iOS
- ShareMenuReactView.continueInApp causes origin app to freeze
- Out of memory crashes are more frequent on iOS 17 when sharing certain URLs HOT 6
- Update example project
- Support "No Share Extension UI" flow on iOS HOT 2
- Add a privacy manifest for XCode 15
- Improve app group configuration for iOS
- Set up changelog format
- Do a test release HOT 1
- Ensure iOS share extension can load files of all types, from all apps
- Report content types more clearly (Android and iOS)
- Add a method to manage copied files on iOS
- Add support for the New Architecture
- v7.0 Tracking issue
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-menu.