So basically I have a code which is already working for android devices, its purpose is to trigger the device's messaging/sms app with a pre-filled text in it. This also opens the iMessage app on iOS with the message already pre-filled successfully, but unfortunately it doesn't support multiple phone numbers.
The following code is currently an example on what I'm trying to do. The returned value from generateURI()
is later used on react native's Linking.openURL()
command.
export function generateURI(arrayOfPhoneNumbers, event) { var url = `sms:` for(var i = 0; i < arrayOfPhoneNumbers.length; i++) { url += `${arrayOfPhoneNumbers[i]},` } url = url.slice(0, -1); //remove last comma url += `${getSMSDivider()}body=Test Message` return url}function getSMSDivider() { return Platform.OS === "ios" ? "&" : "?";}
Things worth noting:
Many URI Scheme patterns and standards don't seem to be respected by Apple as they are listed on the following link: https://tools.ietf.org/html/rfc5724. For instance: every sms field should use the character ?
, but for iOS devices only &
works, on top of that if you encode the string value passed as the body=
attribute, android understands it fine, but iPhones don't. So unfortunately looking at a documented standard is not a viable solution when dealing with Apple's own rulebook.
Also Apple has a very strange statement saying The URL string must not include any message text or other information.
on the following link https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/SMSLinks/SMSLinks.htmlBut that doesn't mean that they don't support multiple phone numbers.