是否可以创建一个包含 url 链接的彩信来启动本地应用程序

发布于 2024-12-20 21:49:51 字数 252 浏览 2 评论 0原文

如果我在短信中嵌入一个网址,然后用户从消息应用程序中单击该网址,我就可以启动我的应用程序。我这一切都在工作。

然而,我希望能够做的是向设备发送一条彩信,其中包含填充屏幕的许多图像和文本,当用户单击彩信中的网址时,我的应用程序将按原样启动如果从短信中单击。

是否可以模拟这个以便我可以看到它的工作原理?即我如何创建一个包含有效活动链接的彩信来演示概念证明(我不是在谈论在 iOS 上以编程方式创建彩信,只是如何创建包含要发送到设备的应用程序 url 的彩信)?

I can launch my app if I embed a url in an SMS and then the user clicks on the url from within the message app. I have this all working.

What I would like to be able to do however is send an MMS to the device which contains a number of image(s) and text filling the screen and when the user clicks on the url within the MMS my app is launched same as it is if clicked from within an SMS.

Is it possible to mock this up so I can see it working? i.e. how could I create an MMS containing a working active link to demo a proof of concept (I'm not talking about creating an MMS programatically on iOS, just how to create one containing my app's url to send to the device)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如果没有你 2024-12-27 21:49:51

编辑:这个答案是在 URL 处理部分需要实现细节的假设下编写的。我将把技术细节留在这里供未来的 Google 员工参考。

此处是论坛主题的链接这似乎表明您无法以编程方式从 iPhone 发送彩信(我知道您说过您无论如何都不想知道这一点,但在这里是为了完整性)。建议直接使用消息提供商的彩信网关(例如http://www.smsglobal.com)。

有关如何将超链接添加到彩信中的说明位于此处。您可以用纯文本编写它,或者使用锚点:不过,不能 100% 确定 iPhone 会正确解析彩信中的这些锚标记。


阅读这篇文章。要点是,您将“URL 类型”行添加到 Info.plist 并将其设置为任何有效协议,例如 myapp,然后用户在彩信中打开一个指向 的链接。 myapp 网址。文章摘录:

<前><代码>myapp://
myapp://some/path/这里
myapp://?foo=1&bar=2
myapp://some/path/here?foo=1&bar=2

iPhone SDK 在启动应用程序以响应上述任何 URL 时,将向 UIApplicationDelegate 发送一条消息。

如果您想提供自定义处理程序,只需在委托中提供消息的实现即可。例如:

- (BOOL)应用程序:(UIApplication *)应用程序句柄OpenURL:(NSURL *)url 
{
  // 对这里的 url 做一些事情
}

Edit: This answer was written under the assumption that implementation details were required for the URL handling part. I'll leave the technical details here for future Googlers.

Here is a link to a forum thread which seems to indicate you can't send MMSes from the iPhone programmatically (I know you said you didn't want to know this anyway, but it's here for completeness). The suggestion is to use a message provider's MMS gateway directly (e.g http://www.smsglobal.com).

Instructions on how to get a hyperlink into an MMS are here. You can just write it in plain text, or use an anchor: <a href="myapp://"> Not 100% sure the iPhone will properly parse those anchor tags in an MMS though.


Read this article. The gist is that you add a "URL types" row to your Info.plist and set it to any valid protocol, say myapp, and then a user opens a link in an MMS to a myapp URL. Article excerpt:

myapp://
myapp://some/path/here
myapp://?foo=1&bar=2
myapp://some/path/here?foo=1&bar=2

The iPhone SDK, when launching the application in response to any of the URLs above, will send a message to the UIApplicationDelegate.

If you want to provide a custom handler, simply provide an implementation for the message in your delegate. For example:

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url 
{
  // Do something with the url here
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文