使用我的网址方案作为链接从SMS打开应用程序 [英] Open app from SMS with my url scheme as a link

查看:330
本文介绍了使用我的网址方案作为链接从SMS打开应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中声明了一个url方案, smstest 所以在Safari中我可以在搜索栏中写入 smstest:my-test smstest:// my-test 我的应用程序已打开。

I declared an url scheme in my app, smstest so in Safari I can write in the search bar smstest:my-testor smstest://my-test and my app is open.

我正在尝试从SMS文本中实现相同的功能,以便消息应用程序格式化 smstest:my-test smstest:// my-test 作为链接,用户可以点击它,我的应用程序被调用。但是文本没有格式化为链接。

I'm trying to achieve the same from a SMS text so the Messages app would format smstest:my-test or smstest://my-test as a link and the user could tap it and my app being called. But the text is not formatted as a link.

是否有可能或者从SMS打开应用程序的唯一解决方案是指向带有脚本的Internet页面?

Is it possible or the only solution to open an app from a SMS is to point to an Internet page with a script?

谢谢。

编辑:有趣的是,我已经安装了IMO Messenger,我收到了一个带有代码作为URL方案的短信,并且已经解析了通过消息应用程序作为链接。为什么我的应用程序没有发生?我尝试了几条消息,在url之前和之后都有空格,没有任何反应。

funny thing, I have installed IMO Messenger and I receive a SMS with a code as an URL scheme, and that is parsed by Messages app as a link. Why does not happens with my app? I tried with several messages, with spaces before and after the url and nothing happens.

推荐答案

一般情况下有标准方式打开应用来自消息应用程序的url方案:

In general there is standard way to open application from Messages app by using url scheme:


  1. 将url方案添加到info.plist文件:my-scheme。

  2. 将应用程序安装到目标iPhone。

  3. 使用以下文本发送短信:my-scheme:// it-is-my-scheme。

一切运作良好。但是这可能是一个有趣的情况,当它不起作用,你认为源代码是但事实并非如此。让我们试着调查一下这个案例:

And everything works well. But it is possible one interesting case when it doesn't work and you think that source code is wrong. But it isn't so. Let's try to investigate this case:


  1. 在添加url方案和安装应用程序之前发送短信正如预期的那样,消息将显示为纯文本:

  1. Before adding url scheme and installing application send SMS. As it expected message will be displayed as plain text:

现在我们将url方案添加到info.plist:

Now lets add url scheme to info.plist:

最后安装应用程序并发送/接收相同的短信:

Finally install application and send/receive the same SMS:

如您所见,上一条消息显示为链接,如果点击它,iOS将打开我的应用程序。 但是第一条消息仍然显示为纯文本,并且不可点击。消息app的逻辑似乎是以这种方式实现的。

As you see last message is displayed like link and if I tap on it then iOS opens my application. But the first message is still displayed as plain text and it isn't tappable. It seems that the logic of Messages app is implemented in such manner.

现在让我们从iPhone删除应用程序并再次发送相同的短信:



现在它再次显示为纯文本,但第二个消息 - 作为链接。如果我点击它,iOS什么都不做,并打开消息应用程序。

Now lets delete application from iPhone and send the same SMS one more time:

Now it again displayed as plain text but the second message - as link. And if I tap on it iOS does nothing and leaves Messages app opened.

结论:确保在安装支持您的方案的应用程序后发送/接收SMS。只有在这种情况下,它才会显示为链接,用户可以通过点击它来打开您的应用程序。

Conclusion: Be sure that you send/receive SMS after installing application that supports your scheme. Only in this case it will be displayed as link and user can open your application by tapping on it.

注意:我还发现一个案例,当安装应用程序时没有支持url方案,然后当我添加此支持消息时显示为纯文本但不显示为链接。我无法重现它。但如果以上步骤无法解决您的问题,请尝试:

Notice: I also catch one case when at the beginning application was installed without supported url schemes and then when I add this support message has been displayed as plain text but not as link. I can't reproduce it. But if above steps won't help to resolve your issue try:


  1. 从iPhone删除应用程序;

  2. 更改网址方案(甚至更改两者:网址方案和捆绑ID作为最后手段);

  3. 再次安装;

  4. 发送短信使用新的网址方案。

  1. Remove application from iPhone;
  2. Change url scheme (or even change both: url scheme and bundle id as a last resort);
  3. Install it again;
  4. Send SMS with new url scheme.

这篇关于使用我的网址方案作为链接从SMS打开应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆