Created
August 7, 2019 06:23
-
-
Save janicduplessis/e769a291fca607b949673e0fa5082e7b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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