【发布时间】:2019-07-14 19:55:48
【问题描述】:
我正在使用 Twilio 功能和可编程 SMS 将 SMS 消息发送到我的 iOS 应用程序中的号码列表。列表中只有 100 多个手机号码(出现此错误时为 113 个)。大多数这些消息都会发送,但随后该函数说它在 502 毫秒后超时。
我正在使用来自 Twilio 的示例代码发送到群组消息(我已在下面复制)并从我的 iOS 应用发出 URLSession 请求。
有没有办法可以解决这个问题,以便我可以发送到这个相当大的电话号码列表或使功能运行更长时间?
非常感谢您的帮助。 汤姆
请求:
let messagesPhoneNumberString = [+447987654321abc,+447123789456def,+447123456789ghi]
"https://myfunction.twil.io/send-messages?phoneAndID=\(messagesPhoneNumberString)&globalID=\(current globalID)"
我的 Twilio 功能代码:
exports.handler = function(context, event, callback) {
let phoneAndIDString = event['phoneAndID'];
let globalID String = event['globalID'];
let numbersArray = phoneAndIDString.split(",");
Promise.all(
numbersArray(number => {
let phoneNumberSplit = "+" + number.slice(1, 13);
let idSplit = number.slice(13);
console.log('Send to number: ' + phoneNumberSplit + ' - with ID: ' + idSplit);
return context.getTwilioClient().messages.create({
to: phoneNumberSplit,
from: 'Example',
body: 'Hello World: ' + idSplit
});
})
)
.then(messages => {
console.log('Messages sent!');
callback(null, response);
})
.catch(err => console.error(err));
};
【问题讨论】:
标签: ios swift sms twilio twilio-functions