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 4 years ago
  • Reactions: 3
  • Comments: 16

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??

any updates on this?

Any update? Having the same issue.

@MateusAndrade Any news about this?

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.