Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 0.16.0 (2022-06-25)

### ✨ Features

* Add mobile props to choose between web link or app link for messenger

Credits

* [@Bunlong](https://github.com/Bunlong)


## 0.14.0 (2022-05-29)

### ✨ Features
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ import {
| to | string | | A user ID of a recipient. Once the dialog comes up, the sender can specify additional people as recipients. | ❌ |
| windowWidth | number | 1000 | Opened window width. | ❌ |
| windowHeight | number | 820 | Opened window height. | ❌ |
| mobile | boolean | false | When `true` the link will be `fb-messenger://share` when `false` it will be `https://www.facebook.com/dialog/send`. | ❌ |

#### 📖 [FacebookMessengerIcon props](https://github.com/Bunlong/next-share#-icons-props)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-share",
"version": "0.14.0",
"version": "0.16.0",
"description": "Social media share buttons for your next React apps.",
"author": "Bunlong <bunlong.van@gmail.com>",
"license": "MIT",
Expand Down
8 changes: 6 additions & 2 deletions src/components/buttons/FacebookMessengerShareButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ type Options = {
/** A user ID of a recipient. Once the dialog comes up, the sender can
* specify additional people as recipients. */
to?: string;
/** A boolean used to choose between fb-messenger://share (Mobile)
* and https://www.facebook.com/dialog/send (Desktop) */
mobile?: boolean;
};

function facebookMessengerLink(
url: string,
{ appId, redirectUri, to }: Options,
{ appId, redirectUri, to, mobile }: Options,
) {
return (
'https://www.facebook.com/dialog/send' +
(mobile ? 'fb-messenger://share' : 'https://www.facebook.com/dialog/send') +
transformObjectToParams({
link: url,
redirect_uri: redirectUri || url,
Expand All @@ -34,6 +37,7 @@ const FacebookMessengerShareButton = createShareButton<Options>(
appId: props.appId,
redirectUri: props.redirectUri,
to: props.to,
mobile: props.mobile,
}),
{
windowWidth: 1000,
Expand Down