自定义 URL 方案有时在 iPhone 中不起作用
我有一个应用程序,我必须从服务器获取消息。服务器通过 SMS 发送消息。由于 iPhone 应用程序无法以编程方式接收短信,因此我注册了一个自定义 URL 方案,并在消息前添加了自定义 URL 值的前缀,例如:mymsg://
。
这在大多数情况下都工作得很好。每当手机收到短信并单击回复按钮时,它会将我带到回复状态,原始消息将显示为一个链接,我可以单击该链接将我带到应用程序。由于某种原因,有时此消息不可点击。也就是说,当我单击消息时,它不会启动应用程序,或者只是消息不可单击。然后,如果我重新启动手机,该链接将再次可单击,我可以单击启动我的应用程序的链接。有谁知道可能是什么原因?
-钦纳杜赖
I have an application where I have to get a message from server. The server sends the message in an SMS. Since iPhone applications cannot receive SMS programatically I have registered a Custom URL scheme and prefixing my message with the custom URL value say for ex: mymsg://
.
This works fine most of the time. Whenever the SMS is received by the phone and I click reply button, it takes me to the reply state and the original message will appear like a link which I can click which takes me to the application. For some reason, sometimes this message is not clickable. That is, when I click on the message it does not launch the application or simply the message is not clickable. Then if i restart the phone, the link is clickable again and i can click on the link which launches my application. Does anyone know what could be the reason?
-chinnadurai
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以前遇到过这个问题,但我不确定这是否与您遇到的问题相同。我发现,Messages.app 中的自定义 URL 方案是否可点击是在消息到达时确定的,而不是在用户看到 URL 时确定的。
这意味着,如果您在用户下载应用程序之前向他们发送自定义方案 URL,则该链接将永远不可点击,即使他们稍后继续下载应用程序也是如此。我仅在 iOS 7.1 上验证了此行为(尚未检查其他版本)。
就我而言,我无法保证在发送消息时用户已经下载了应用程序,因此我的解决方案是使用重定向到自定义
的标准
服务器上的 URL,具有 302 重定向。希望这有帮助!http://
url >myapp://I've encountered this issue before but I'm not sure it's the same one you're having. What I discovered is that whether or not a custom URL scheme is clickable in Messages.app is determined when the message arrives, not when the user sees the URL.
What this means is that if you send the user your custom scheme URL before they've downloaded the app, that link will never be clickable, even if they go on to download the app at a later time. I've verified this behavior on iOS 7.1 only (haven't checked other versions).
For my case, I can't guarantee that the user has already downloaded the app when I send the message, so my solution was to use a standard
http://
url that redirects to the custommyapp://
URL on the server with a 302 redirect. Hope this helps!