Skip to content

Instantly share code, notes, and snippets.

@janicduplessis
Created August 7, 2019 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janicduplessis/e769a291fca607b949673e0fa5082e7b to your computer and use it in GitHub Desktop.
Save janicduplessis/e769a291fca607b949673e0fa5082e7b to your computer and use it in GitHub Desktop.
const onInvitePress = () => {
let didShare = false;
const message = `Try my cool app`;
const emails = selectedContacts
.filter(c => c.email != null)
.map(c => c.email) as string[];
const phoneNumbers = selectedContacts
.filter(c => c.phoneNumber != null)
.map(c => c.phoneNumber) as string[];
if (emails.length > 0) {
try {
const result = await composeAsync({
recipients: emails,
subject: 'Hello friend',
body: message,
isHtml: false,
});
didShare = didShare || result.status === 'sent';
} catch (ex) {
Alert.alert(ex.message);
}
}
if (phoneNumbers.length > 0 && (await isAvailableAsync())) {
try {
const result = await sendSMSAsync(phoneNumbers, message);
didShare = didShare || result.result === 'sent';
} catch (ex) {
Alert.alert(ex.message);
}
}
if (didShare) {
Alert.alert('Thanks for sharing!!');
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment