0

I have to text several of my contacts.

At the time of the permission request the application crashes completely. Once the application is restarted, the sms are sent. I think the problem is that the application does not wait for confirmation of permission. The problem is with Android.

    sms.contacts.forEach(async contact => {
      try {
        // Send sms
        await this.sms.send(contact.phoneNumbers[0].value, this.messageText)
      } catch (error) {
        this.errorsMsg.push(error)
        this.isOk = false
      }
    })

Somebody can help me ?

  • I think that you have an error in your logic. Look this - are you using async/await syntax but only inside your forEach loop. IMO this cause that first success await code permit application to go for the next part of your application. More details end better explain of this you can find hire: https://stackoverflow.com/a/37576787/2972087 – kris_IV May 21 '19 at 17:14

1 Answers1

0

Thanks to kris_IV for his help.

As this post says, i just needed to use the for loop

for (const contact of sms.contacts) {
  try {
    await this.sms.send(contact.phoneNumbers[0].value, this.messageText)
  } catch (error) {
    this.errorsMsg.push(error)
    this.isOk = false
  }
}