[英]Sending a SMS in a Progressive Web App Doesn't Always Work on iPhone
I have made a progressive web app.我制作了一个渐进式网络应用程序。 One part of it should update a mysql database and prepare to send a SMS.其中一部分应该更新mysql数据库并准备发送短信。 It seems to work well on Android but is erratic on iPhone.它似乎在 Android 上运行良好,但在 iPhone 上不稳定。 When it goes wrong, the iPhone shows "sms:+4412345678?&body=1" in the browser address bar instead of opening the SMS app.出错时,iPhone在浏览器地址栏中显示“sms:+4412345678?&body=1”,而不是打开短信应用程序。
The html is html是
<a href="sms:+4412345678?&body=1"><button class="1">Going to RV</button></a>
<a href="sms:+4412345678?&body=2"><button class="2">Going to Station</button></a>
<a href="sms:+4412345678?&body=3"><button class="3">Delayed but Attending</button></a>
<a href="sms:+4412345678?&body=4"><button class="4">On Scene</button></a>
<a href="sms:+4412345678?&body=5"><button class="5">Not Attending</button></a>
Then I have a Jquery function然后我有一个 Jquery 函数
$(function(){
$('button').click(function(){
var callsign = "<?php echo $callsign ?>";
var response = $(this).attr("class");
$.ajax({
url: 'myresponse.php',
type: 'POST',
data: {callsign: callsign,
response: response}
}).done(function() {
$("#beforeresponse").css("display", "none");
$("#tresponse").css("display", "block");
$("#teamresponse").load("allresponses.php div#teamresponse");
});
});
});
I think perhaps the two tasks are tripping over each other and causing a problem depending on which starts or finishes first.我认为这两个任务可能会相互绊倒并导致问题,具体取决于哪个先开始或先完成。 Does that sound feasible?这听起来可行吗?
I am wondering whether I can disable the links我想知道我是否可以禁用链接
<a href="sms:+4412345678?&body=1" disabled="disabled"><button class="1">Going to RV</button></a>
and then trigger the SMS with a .done function after the existing .done is completed.然后在现有的.done完成后用.done函数触发短信。 If so, how?如果是这样,如何?
Or am I completely wrong?还是我完全错了?
Well I finally worked out the answer.好吧,我终于找到了答案。 I hope this may be of use to someone else.我希望这对其他人有用。
The link "sms:+4412345678?&body=1" works when the page is opened in a browser window, but not when it is installed as a web app.链接“sms:+4412345678?&body=1”在页面在浏览器窗口中打开时有效,但在作为网络应用程序安装时无效。 So for this particular app where the SMS message is a fundamental part of the functionality, I have to steer iPhone users to just place a shortcut on their home page, while Android users can install the app in the normal proper way.因此,对于这个 SMS 消息是功能的基本组成部分的特定应用程序,我必须引导 iPhone 用户在他们的主页上放置一个快捷方式,而 Android 用户可以以正常的正确方式安装该应用程序。
It feels a bit hacky, but it's a solution.感觉有点hacky,但它是一个解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.