Skip to content

Commit

Permalink
Add restriction such that at least a link or text parameter must …
Browse files Browse the repository at this point in the history
…be passed to sharing methods
  • Loading branch information
Jberlinsky committed Feb 10, 2017
1 parent adc4ccb commit 1f04940
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ The options object lets you pre-populate the share view for the user. You can us
| image | Adds an image file from the xcode image assets. image takes priority over imagelink. Only one out of two will load. |
| link | Adds a URL to the message. The method automatically handles the URL shortening. |

**At least the `text` or `link` parameter must be specified**

### Callback
The callback function runs when the native environment has information for the react environment
Expand Down
12 changes: 10 additions & 2 deletions react-native-social-share.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ var KDSocialShare = require('react-native').NativeModules.KDSocialShare;

module.exports = {
shareOnTwitter: function(params, callback) {
return KDSocialShare.tweet(params, callback);
if (!(params['link'] || params['text'])) {
callback("missing_link_or_text");
} else {
return KDSocialShare.tweet(params, callback);
}
},
shareOnFacebook: function(params, callback) {
return KDSocialShare.shareOnFacebook(params, callback);
if (!(params['link'] || params['text'])) {
callback("missing_link_or_text");
} else {
return KDSocialShare.shareOnFacebook(params, callback);
}
}
};

0 comments on commit 1f04940

Please sign in to comment.