最近做了一个功能需要通过html代码调用手机的系统自带的短信功能,采用和tel:手机号码一样的方式使用sms:10086来处理:
copyToPaste(item) {
try {
if (item.style === 'phone') {
this.presentAlertConfirm(item.value);
} else if (item.style === 'weixin') {
this.copyUrl(item.value);
// 唤起微信
} else if (item.style === 'message') {
// 复制将要发送的短信信息
// this.copyUrl(item.value);
const nickName = localStorage.getItem('currentNickName') ? localStorage.getItem('currentNickName') : '';
const platformStr = localStorage.getItem('platform');
const specialSymbol = platformStr === 'ios' ? '&' : '?';
// sms:10086?body=您好,我是蜂喔,给您推荐了信息,请及时到蜂喔APP查看哦
document.location.href = "sms:" + item.value + specialSymbol + 'body=您好,我是蜂喔科技的' + nickName + ',给您推荐了信息,请及时到蜂喔APP查看哦';
}
} catch (error) {
console.log('error:' + JSON.stringify(error));
}
}
ios手机使用的是&符号来连接短信内容。