fluttercommunity / flutter_sms

A Flutter plugin to Send SMS and MMS on iOS and Android. If iMessage is enabled it will send as iMessage on iOS. This plugin must be tested on a real device on iOS. Maintainer: @rodydavis
https://fluttercommunity.github.io/flutter_sms/
MIT License
245 stars 182 forks source link

sendSMS change result to enum instead of string #8

Closed kmcgill88 closed 5 years ago

kmcgill88 commented 5 years ago

I noticed you return a Future<String> from sendSMS. What do you think about changing to Future<SendResult>.

String _result = await FlutterSms.sendSMS(message: "yo dawg", recipients: ["1234567890"]);
print("Result is: $_result");
if (_result == "not clear what the result options are") {
// stuff
}

to

SendResult _result = await FlutterSms.sendSMS(message: "yo dawg", recipients: ["1234567890"]);
print("Result is: $_result");
if (_result == SendResult.success) {
// stuff
}

Doing something like SendResult.success would allow pushing the string comparison down into your library and consumers have an easier interface with the enums to determine the result. I'd be happy to implement this if you agree.

kmcgill88 commented 5 years ago

Have you had enough time to review this idea?

rodydavis commented 5 years ago

Yes I would definitely be open to that. Please feel free to do a pull request. I will also look and see if I can update the implementation. Thank you!

rodydavis commented 5 years ago

Fixed with the PR and: flutter_sms: 0.0.4

hinterlandcreative commented 4 years ago

@rodydavis Was this actually done? It looks like sendSMS is still returning a string?

rodydavis commented 4 years ago

I am still testing but the latest on GitHub returns a string.

Once I fix the bugs I’ll publish the new version.

Works on iOS and web for me really well