iOS:启动包含多个收件人的邮件应用程序 [英] iOS: Launching Messages app with multiple recipients
问题描述
我尝试进行设置,以便我的用户可以向一组人发送文本。现在用电子邮件很简单,URL方案只是 mailto://firstemail@email.com,secondemail@email.com
,然后可以使用 openURL
方法。
I'm trying to set it up so my user can send a text to a group of people. Now with email it's simple, the URL scheme is just mailto://firstemail@email.com,secondemail@email.com
which can then be used with the openURL
method.
当我来到短信时,我决定尝试 sms:// 2065555555,2061234567
但是这不工作(它只添加第一个数字)。在浏览Google之后,我发现一些旧线程声称使用URL方法不能向多个收件人发短信。
Naturally when it came to SMS I decided to try sms://2065555555,2061234567
however this doesn't work (it only adds the first number). After browsing Google a bit, I found some older threads claiming that texting to multiple recipients isn't possible using the URL method.
为了向多个人发送邮件,我已经开始向我的应用程序添加 MessageUI
,挂接了 MFMessageComposeViewControllerDelegate
,现在我可以发送同时向多个人发送消息。但是只有从我自己的应用程序,这不是我想要的。我希望在框架中有一些东西,这将允许我利用多个收件人的功能,然后在默认消息中启动它,但我找不到任何允许这样。
In order to send a message to multiple people, I've gone ahead and added MessageUI
to my application, hooked up the MFMessageComposeViewControllerDelegate
, and now I can send indeed send messages to multiple people at once. However only from within my own application, which is not what I want. I was hoping there'd be something in the framework that would allow me to take advantage of the multiple recipients functionality and then launch it in the default messenger, but I can't find anything that allows that.
因此,总之,有没有可能的方式,我可以编写我的应用程序来填充默认的消息应用程序与多个收件人?任何帮助将不胜感激,谢谢。
So, in short, is there any possible way I can code my app to populate the default Messages app with multiple recipients? Any help would be appreciated, thank you.
编辑:实际上我确定必须有一个方法来做,我只是检查了应用程序Cobook,他们允许
Actually I'm certain there must be a way to do it, I just checked the app Cobook and they allow the user to select contacts then launch the Messages app sending a "New Group MMS".
推荐答案
我发现这是一个很老的问题 - 但我发现最近做的方法,并在这里张贴:
I realize this is a very old question - but I discovered the way to do it recently, and posted about it here:
虽然这个答案是watchkit具体的,url实际上是你要的。
While this answer is watchkit specific, the url is really what you are asking about.
ANSWER :
I 找到一个晦涩的页面,给了我的答案。事实证明,它没有记录在任何地方我可以找到:
ANSWER: I found an obscure page that gave me the answer. Turns out it is not documented by Apple anywhere I could find:
let urlSafeBody = messageBody.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLHostAllowedCharacterSet())
if let urlSafeBody = urlSafeBody, url = NSURL(string: "sms:/open?addresses=1-408-555-1212,1-408-555-2121,1-408-555-1221&body=\(urlSafeBody)") {
WKExtension.sharedExtension().openSystemURL(url)
}
b $ b
上述版本将打开Apple Watch上的消息应用程序,并预填充多个收件人。
The above version will open the messages app on the Apple Watch with multiple recipients pre-populated.
有 多页 表示不可能,但它是。 Hooray!
There are many pages that state it isn't possible, but it is. Hooray!
这篇关于iOS:启动包含多个收件人的邮件应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!