I have an app built in react-native in which I need to share a post on LinkedIn with predefined content.
I used 'react-native-share' for sharing content on LinkedIn but It's not working. How can I achieve this?
Thanks in advance.
I have an app built in react-native in which I need to share a post on LinkedIn with predefined content.
I used 'react-native-share' for sharing content on LinkedIn but It's not working. How can I achieve this?
Thanks in advance.
LinkedIn supports only one parameter being passed to it, and that is the url
parameter. It will look like this...
https://www.linkedin.com/sharing/share-offsite/?url={url}
Source: Official LinkedIn Sharing Documentation.
The following parameters will not work: summary
, title
, source
, etc.. Anything besides url
.
To share to LinkedIn, just make a <a href>
element that points to an above formatted-URL, and make absolutely sure to do URL-encoding on your {url}
.
You probably want to share title
and summary
, though, based on the accepted answer. You cannot do that using GET
-data, BUT you can do that using og:
tags.
<meta property='og:title' content='Title of the article"/>
<meta property='og:image' content='//media.example.com/ 1234567.jpg"/>
<meta property='og:description' content='Description that will show in the preview"/>
<meta property='og:url' content='//www.example.com/URL of the article" />
Source: LinkedIn Developer Docs: Making Your Website Shareable on LinkedIn.
In case you are uncertain that you've followed the LinkedIn documentation correctly to make a share URL, you can test your page's URL to see how it will look when shared here: LinkedIn Post Inspector.
You can do it with react-native-share
. I have used it in one of my application.
const shareOptions = {
title: 'Share via',
message: `Hello, ${description}`,
subject: 'Subject,
url: "data:image/png;base64," + base64Data,
showAppsToView: false,
filename: 'test',
};
Share.open(shareOptions).then(res => {
console.log(res)
}).catch(e => {
console.log(e)
});
Note: It would be greater if you can share your code.
You can use Linking from react native
import { Linking } from 'react-native';
and then you can use
Linking.openURL("https://www.linkedin.com/shareArticle?mini=true&summary=youtube&title=f1&url=https://www.youtube.com/watch?v=dQw4w9WgXcQ");
you can found more info here https://stackoverflow.com/a/10737122/6125249