What would be the best practice approach of sending SMS message programatically in Kotlin Multi Platform Compose for both iOS and Android?
b
brandonmcansh
11/14/2023, 11:46 PM
first thought would be an expect/actual contract to handle the platform specific dispatching of things
💡 1
s
Sasa Blagojevic
11/15/2023, 12:11 AM
I had the same thought, so far I came up with this, by default the "intent approach":
on android that would be something like
Copy code
Uri uri = Uri.parse("smsto:12346556");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.putExtra("sms_body", "Here you can set the SMS text to be sent");
startActivity(it);
and on iOS:
Copy code
MFMessageComposeViewController
So those would be the equivalent "intent based" approaches.
On Android there is also an option to use
SmsManager
but that requires
SEND_SMS
permission
j
jw
11/15/2023, 12:27 AM
I wouldn't even do expect/actual. That sounds like an interface with two distinct implementations.
b
brandonmcansh
11/15/2023, 12:30 AM
Ya that probably makes more sense now that I actually think about it.
r
Ryan Simon
11/15/2023, 5:18 AM
Yeah I like to default to interfaces. Most of the time expect/actual isn't needed.