2017-11-18 244 views
1

好日子,我想在不使用Cordova SMS插件的情况下自动发送短信。我想在注册该应用程序之后将验证码发送给每位客户。有没有办法做到这一点?希望您能够帮助我。先谢谢你。我正在使用Ionic 2。在不使用科尔多瓦插件的情况下在Ionic 2中发送短信

+0

有没有什么方法可以使用插件而无需打开消息应用程序(自动发送短信)。 – Patrick

回答

0

如果您有一个后端运行,那很容易。本示例使用节点Nexmo SMS API

app.post('/', (req, res) => { 
    res.send(req.body); 
    const toNumber = req.body.number; 
    const text = req.body.text; 
    nexmo.message.sendSms(
    NUMBER, toNumber, text, {type: 'unicode'}, 
    (err, responseData) => { 
     if (err) { 
     console.log(err); 
     } else { 
     console.dir(responseData); 
     } 
    } 
); 
}); 

查看this article的完整示例。

+0

谢谢,但我如何在离子2中使用它? – Patrick

+0

@Patrick使用此代码运行一个节点服务器,并对服务器执行Ajax api调用(POST)以使其发送短信。试试这些文章:[发送短信](https://scotch.io/tutorials/send-sms-from-the-browser-with-web-apis-node-and-exmo),[异步API调用](https: //medium.com/codingthesmartway-com-blog/getting-started-with-axios-166cb0035237) – janekkkk