Code Monkey home page Code Monkey logo

Comments (25)

ajith-ab avatar ajith-ab commented on June 2, 2024 2

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.

caiosba avatar caiosba commented on June 2, 2024 1

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.

sixmoraltales avatar sixmoraltales commented on June 2, 2024 1

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.

sixmoraltales avatar sixmoraltales commented on June 2, 2024 1

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.

ajith-ab avatar ajith-ab commented on June 2, 2024 1

i ve used this package react-native-receive-sharing-intent

from react-native-share-menu.

infojunkie avatar infojunkie commented on June 2, 2024 1

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.

caiosba avatar caiosba commented on June 2, 2024

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.

sixmoraltales avatar sixmoraltales commented on June 2, 2024

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.

caiosba avatar caiosba commented on June 2, 2024

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.

sixmoraltales avatar sixmoraltales commented on June 2, 2024

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.

caiosba avatar caiosba commented on June 2, 2024

Yes! on the callback side, please make sure that title is not mandatory.

from react-native-share-menu.

sixmoraltales avatar sixmoraltales commented on June 2, 2024

Any recommendations on how I would ensure it's not mandatory?

from react-native-share-menu.

caiosba avatar caiosba commented on June 2, 2024

I mean, just make sure that the callback still works if the title is not present.

from react-native-share-menu.

sixmoraltales avatar sixmoraltales commented on June 2, 2024

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.

caiosba avatar caiosba commented on June 2, 2024

Probably not set by the browser then :(

from react-native-share-menu.

sixmoraltales avatar sixmoraltales commented on June 2, 2024

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.

sixmoraltales avatar sixmoraltales commented on June 2, 2024

Ah, good idea. I'll try it.

from react-native-share-menu.

sixmoraltales avatar sixmoraltales commented on June 2, 2024

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.

caiosba avatar caiosba commented on June 2, 2024

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.

caiosba avatar caiosba commented on June 2, 2024

You're welcome, good luck. If you find another solution please update here.

from react-native-share-menu.

sixmoraltales avatar sixmoraltales commented on June 2, 2024

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.

sixmoraltales avatar sixmoraltales commented on June 2, 2024

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.

caiosba avatar caiosba commented on June 2, 2024

Reopening and labeling as "feature".

from react-native-share-menu.

qsdamar avatar qsdamar commented on June 2, 2024

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.

jayeshkarma100 avatar jayeshkarma100 commented on June 2, 2024

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)

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.