Sharing a post

Constellational (the app I’m building to give your notes a home online) lets you share posts via the usual suspects – email, message, Twitter, Facebook, etc. I’m doing this using React Native’s ActionSheetIOS.

When a post is tapped a bunch of options show up (Share, Edit, Delete or Cancel), and if Share has been tapped (buttonIndex is zero) the Share sheet is displayed.

This is the code that we’re interested in:

showOptions() {
options: ['Share', 'Edit', 'Delete', 'Cancel'],
destructiveButtonIndex: 2,
cancelButtonIndex: 3
}, (buttonIndex) => {
var url = URL + '/' + SettingStore.getUsername() + '/' +;
if ( || {
var options = {message:};
} else {
var options = {url: url};
if (buttonIndex === 0) {
ActionSheetIOS.showShareActionSheetWithOptions(options, this.shareFailure, this.shareSuccess);
} else if (buttonIndex === 1) {
this.props.nav.push({id: 'edit', post:});
} else if (buttonIndex === 2) {
if ( {
} else {

Note that if the post is being edited or is still a draft the post contents are shared (for example, if you chose email the body of the mail will be the text of the post). A link is shared if you’ve published the post. Still to come: opening these links in the app instead of the browser. Sounds interesting? Sign up here!