2

I would like to send the same message by SMS to multiple recipients. But don't want recipients to know each other (like BCC in emails). And I don't want to use an external SMS sender.

I'm currently using Xamarin.Essentials.Sms to compose the message with multiple recipients.

 public async Task<bool> TryOpenSmsAsync(string message, List<string> recipients)
        {
            try
            {
                var smsMessage = new SmsMessage(message, recipients);
                await Sms.ComposeAsync(smsMessage);
                return true;
            }
            catch (FeatureNotSupportedException ex)
            {
                // Sms is not supported on this device.
                return false;
            }
            catch (Exception ex)
            {
                // Other error has occurred.
                return false;
            }
        }

SMS composed is prefilled correctly, with the recipients. But if I send it, all recipients can view the phone numbers of other recipients. In my case, this is a security issue.

I doesn't seem possible to remove any group messaging options using Xamarin Essentials.

While searching, i found that it is possible to disable the Group Messaging options, but it requires the user to perform complex actions (which is not what i want) :

  • on iOS in Settings --> Messages
  • on Android it depends on the messaging app.

Is it possible to achieve this ? Or maybe an alternative ?

Alfa
  • 43
  • 1
  • 6
  • 1
    Instead of sending the SmsMessage to all recipients in one go you can just loop over each recipient and send the message individually. – Robin Sep 27 '22 at 13:41
  • Thanks, but this solution is not acceptable: if I have 30 recipients, the messaging app of the device will be displayed 30 times and the user will have to send each message individually (press 30 times "Send"). Not really usable. This come with the compose feature. And sending in background is forbidden on iOS... – Alfa Sep 27 '22 at 15:17
  • Because you already have a list of recipients, simply loop over SmsMessage() for each recipient. If you want to send the identical message to 30 persons, one click will send SmsMessage() to each of them and not 30 clicks. That's what @Robin suggests. To handle the message send notification that will show up every time the user clicks a Send button, you must tweak it slightly so that it only displays one notification with a list of recipients. – ecle Sep 28 '22 at 04:07
  • Sorry but I tryied this exactly, and it really opens multiple windows if no default messaging app is set. If a default one is set, i just opens compose Window of the first recipient. Please note that the method called is Compose(), and not Send() (which doesn't exists). – Alfa Oct 04 '22 at 12:34
  • Why you don't just send to group of recipients. If its SMS, noone will see to whom else you had sent. – Marvin Oct 23 '22 at 00:44
  • That is exactly what i'm doing (see my post). But behind the scene, list of recipients are handled differently on different platforms. Messages can be sent using either, mms messaging, iMessage (iOS), sms messaging. On the first two, recipients are visible to each other. That's why I want to force the later one : SMS messaging. – Alfa Oct 24 '22 at 08:20

1 Answers1

0

As Robin said, you can loop over each recipient and send the message individually.

public async Task<bool> TryOpenSmsAysnc(string message,List<string> recipients)
        {
            try
            {
                foreach (var item in recipients)
                {
                    var smsMessage = new SmsMessage(message, item);
                    await Sms.ComposeAsync(smsMessage);
                }
                return true;

           }catch(FeatureNotEnabledException ex)
            {
                return true;
            }
            catch (Exception ex)
            {
                return true;
            }
        }
Jianwei Sun - MSFT
  • 2,289
  • 1
  • 3
  • 7
  • No, this doesn't work. It opens multiple "Compose message" windows if no default messaging app is set. And only 1 if a default messaging app is set. Note that ComposeAsync() is called. This doesn't send a message, but opens the default SMS application of the device, prefilling it. – Alfa Oct 04 '22 at 12:39
  • 1
    Sorry about that. As you said that "the method called is Compose(), and not Send() (which doesn't exists). It opens multiple "Compose message" windows if no default messaging app is set". SMS can't achieve your need. For more details, you can check this [link](https://learn.microsoft.com/en-us/dotnet/api/xamarin.essentials.sms?view=xamarin-essentials). – Jianwei Sun - MSFT Oct 06 '22 at 02:39