PWA iOS getting the sms: tag to open iMessage

心不动则不痛 提交于 2020-04-18 04:00:35

问题


We are currently developing a PWA for a client of ours. Everything has been going well, but while testing on iPhone (iOS 12.2) we are having an issue with the tags that have sms:123-456-7890 in the href. You get the "Safari cannot open this page because of the sms: tag" (paraphrasing).

If you are browsing the site via Safari (not in the PWA mode), the anchor tag works fine and your iMessage opens up with the number in it. But when you're in the PWA mode and click the link, you get a version of the message I mentioned above.

From doing research, this appears to be some sort of bug in the iOS 12.2 release, though not officially mentioned.

I'm curious if anyone has had any luck with a work-around for this issue?

Thanks in advance.

Edit..to add some code for the anchor tag....

<a href="sms://1234567890;">123-456-7890</a>

I've tried many different variations of the sms (with no // or ;), always same outcome when clicking it as a PWA. With Android, everything works fine in PWA mode.


回答1:


I did find a workaround by using JavaScript

Code Example:

<a href="#" onclick="openSMSMobile();" >

function openSMSMobile(e) {           
        window.open('sms:1234567890', '_self');
        return false;
    }



回答2:


And in case anyone is wondering, if you'd like to add text to the message body, you can use,

window.open('sms:1234567890&body=textGoesHere', '_self');

For Android you'll need,

window.open('sms:1234567890&body=textGoesHere', '_self');


来源:https://stackoverflow.com/questions/56279227/pwa-ios-getting-the-sms-tag-to-open-imessage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!