我正在尝试使用sms插件来发送sms,但是每当我尝试发送sms并且sms.hasPermission()始终为false时,它总是崩溃。请让我知道如何请求短信许可并发送短信? https://ionicframework.com/docs/native/sms
this.sms.hasPermission().then(hasPermission => {
console.log("hasPermission",hasPermission);
if(hasPermission){
this.sms.send(i.phoneNumber, message, {
replaceLineBreaks: false, // true to replace \n by a new line, false by default
android: {
intent: 'INTENT' // send SMS with the native android SMS messaging
//intent: '' // send SMS without opening any other app
}
});
} else{
console.log("eror");
}
})
https://ionicframework.com/docs/native/android-permissions的正确实现
强烈建议您在android ionic项目上访问任何本机功能。
离子SMS插件可能有问题,所以我从https://github.com/akashpjames/smsApp/blob/master/src/app/tab1/tab1.page.ts那里获得了参考,并且工作正常