Unable to send sms with loop

hi all!
I am trying to send sms with loop and some timer because android will block big amount of sms. I am using ionic 1.x and Cordova. my code is:

    `  var i = 0;
    function nextFrame() {
      if(i < contacts.length) {
        var contact = contacts[i];
        if (contact.hasOwnProperty('number')) {
            .send(contact.number, text);

    // Continue the loop in 3s
    setTimeout(nextFrame, 3000);`