Essentials: SMS API - Add support multiple recipients

Created on 16 Jul 2018  路  5Comments  路  Source: xamarin/Essentials

Steps to Reproduce

Build an app that uses the SMS API to prefill an SMS with multiple recipients (one string with recipients separated with a semi-colon)

Expected Behavior

Add as many recipients as there are in the passed string.

Actual Behavior

On iOS at least, it only adds the last one i.e. when passed "tel1;tel2;tel3;" it only displays tel3.
Not able to test on Android just now but, looking at the code, it might work as the "smsto" uri seems to support multiple recipients separated with a semi-colon (cf https://stackoverflow.com/questions/10265480/android-opening-sms-activity-with-multiple-recipients-specified)

Basic Information

Device Tested On: iPhone 6s / 7 plus - iOS 11.4
Simulator Tested On: N/A
Version of VS: Version 7.5.3 (build 7) for Mac
Version of Xamarin: Xamarin.iOS 11.12.0.4

EDITED by @redth with API Spec:

API Spec

SmsMessage
Remove: public string Recipient { get; set; }
Add: public IList<string> Recipients { get; private set; }

Remove: public SmsMessage(string body, string recipient)
Add: public SmsMessage(string body, params string[] recipients)

good-first-issue in-progress proposal

All 5 comments

Moved to proposal and updated title as a feature request.

Looks to me like MFMessageComposeViewController supports multiple recipients so that should be fine to support.

Android supports sms with smsto:1234567;1234568 however we currently also set the address extra with the recipient. Might need to do testing to see if we can use ; in that extra or not, and maybe we are ok to just remove that extra altogether.

UWP looks like it easily supports multiple recipients.

What if we make:

public string[] Recipients { get; set; }

If we do that I think we may as well make it immutable (private set)

I made a comment on the PR to rather use a List<T> - this is also consistent with email:

public List<string> Recipients  { get; set; } = new List<string>();

I would like to be able to do:

var msg = new SmsMessage {
  Recipients = SomeList
};

AND

var msg = new SmsMessage {
  Recipients = {
    "1234",
    "5678"
  }
};
Was this page helpful?
0 / 5 - 0 ratings