react-native-share: Share.open options are not working well (title, icon does not show)

Ask your Question

I want to use Share.open() with my custom values, but it does not work as expected. In iOS, activityItemSources option goes well but it does not display icon that I want to show. Moreover in android, title does not come up and I can see just only messages and url. (In addition, I want to show message only in sharesheet and share the url value only, but android shows and shares both message and url. Isn’t there any options to customize it?)

This is a capture that what it goes like

image

and this is my code

const onShare = async () => {
    try {
      const url = 'https://real-value-to-share-with'
      const title = 'HI THIS IS TITLE'
      const message = 'and this is just a message'
      const icon = 'data:<data_type>/<file_extension>;base64,<base64_data>'
      const shareResponse = await Share.open(
        Platform.select({
          ios: {
            failOnCancel: false,
            activityItemSources: [
              {
                placeholderItem: { type: 'text', content: message },
                item: { default: { type: 'url', content: url } },
                linkMetadata: { title, originalUrl: message, icon },
              },
            ],
          },
          default: { failOnCancel: false, message, url, title, },
        }),
      )
      console.log(shareResponse)
    } catch (error) {
      console.error(error)
    }
  }

What I want to do

  • show title and message individually
  • distinguish value to show in ShareSheet from value to share with (just like what iOS does now)
  • (optional) show custom icon

What I use

libraries version
react-native 0.63.2
react-native-share ^3.7.0
typescript ^3.8.3

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 18

Most upvoted comments

I found that in ios, regardless of icon option, if there is any url or originalUrl option, it just shows default url icon

image

linkMetadata: {
            title: 'Title',
            originalUrl: 'originalUrl',
          },

image

linkMetadata: {
            title: 'Title',
            url: 'url',
          },

image

linkMetadata: {
            originalUrl: 'originalUrl',
            url: 'url',
          },

.

but if not, (if there is title only or no options exist) it shows the app icon

image

linkMetadata: {
            title: 'Title',
          },

image

linkMetadata: { },

all above case, I didn’t give any icon or image options does there anyone know that is this bug or not??

Well, the thing about the stale bot is that it is on objective measure of how much the community cares. No one apparently cares enough to propose a PR, so it is objectively not interesting. Real time actually passed. Nothing happened. Or someone would have proposed a PR. Open Source software is not magic, it requires effort.

any updates on this?

Any update? Having the same issue.

@MateusAndrade Any news about this?

Dead project. Basic options like “title” and “icon” don’t even work, for years.

Off topic for this issue, but can’t resist to comment on @mikehardy 's comment, which I totally agree with, btw.

There’s a lot of RN developers out there that don’t have experience in native at all. Maybe this is the reason why there’s such low interest in posting PRs to RN repos in general? There’s also some projects which have an unsurmountable amount of process to get a PR in. I spend 8-9 hours each workday writing software or solving software related problems for business, I rarely have the energy to spend more time on top of that to jump process hoops for sometimes extremely trivial PRs.