What would be the best practice approach of sendin...
# multiplatform
s
What would be the best practice approach of sending SMS message programatically in Kotlin Multi Platform Compose for both iOS and Android?
b
first thought would be an expect/actual contract to handle the platform specific dispatching of things
💡 1
s
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
I wouldn't even do expect/actual. That sounds like an interface with two distinct implementations.
b
Ya that probably makes more sense now that I actually think about it.
r
Yeah I like to default to interfaces. Most of the time expect/actual isn't needed.
1
👍 1
147 Views