Send Text Message To Multiple Number In Xamarin Android

Ali_LashariAli_Lashari ✭✭USMember ✭✭

How to Send Sms To Multiple Numbers using Sms Manager in Android Xamarin.... Any sample code to do that???

Best Answer

Answers

  • hexagodhexagod ✭✭✭ Member ✭✭✭

    How about this:

    https://github.com/xamarin/recipes/tree/master/Recipes/android/networking/sms/send_an_sms

    Then create a loop for every number

            sendSMS.Click += (sender, e) => {
    
    
            int[] myArray = new int[] { 999, 989, 929, 979, 959 };
    
            foreach (int phoneNumber in myArray )
            {
                    SmsManager.Default.SendTextMessage (phoneNumber, null, "hello from Xamarin.Android", null, null);
            }     
    

    };

  • hexagodhexagod ✭✭✭ Member ✭✭✭

    EDIT: actually I think SendTextMessage takes strings not int so

            string[] myArrary = { "989", "929", "933" };
    
            foreach (string phoneNumber in myArray)
            {
                SmsManager.Default.SendTextMessage(phoneNumber, null, "hello from Xamarin.Android", null, null);
            }
    
  • hexagodhexagod ✭✭✭ Member ✭✭✭

    ^^^ *** there is no edit button on here!!!! completely ridiculous .. I misspelled myArray ... sorry I'm trying to work on some other stuff

    string[] myArray = { "989", "929", "933" };
    
    foreach (string phoneNumber in myArray)
    {
          if (phoneNumber != null) 
         {
            SmsManager.Default.SendTextMessage(phoneNumber, null, "hello from Xamarin.Android", null, null);
         }
           else
          {
            //nothing
          }
    }
    
  • Ali_LashariAli_Lashari ✭✭ USMember ✭✭
    Thanks #hexagod For your Reply .Could you Please tell me How can we Do this with using EditText With Multiple Numbers Input in that Single EditText........Regards
  • hexagodhexagod ✭✭✭ Member ✭✭✭

    I'm not sure exactly what you're referring to... but you need to lookup "How to store strings into an array from EditText control xamarin" .. that should get you pretty close. Basically you're going to use that EditText control to add your strings into an array then you can run that loop I gave you to send all the messages

  • Ali_LashariAli_Lashari ✭✭ USMember ✭✭

    Yes that Is what I Trying to do......Could u please tell how to do that?

  • Ali_LashariAli_Lashari ✭✭ USMember ✭✭

    Lol hahahahah thanks #hexagod.Yes I have Done it Now ... :smile:

Sign In or Register to comment.