ios - SMS WatchKit 多个数字分隔符

标签 ios swift sms watchkit nsurl

我在让我的 WatchKit 应用程序预先编写一条 SMS 消息给多个收件人时遇到了一些麻烦(通过 Apple Watch 消息应用程序)。

    let messageBody = "hello test message"
    let urlSafeBody = messageBody.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLHostAllowedCharacterSet())
    if let urlSafeBody = urlSafeBody, url = NSURL(string: "sms:8888888888&body=\(urlSafeBody)") {
        WKExtension.sharedExtension().openSystemURL(url)

我的问题是,如果您有多个电话号码要从 watch 向其发送消息,您如何分隔这些值?

SMS Links 文档条目没有解释从 NSURL 到多个 recips 的分隔。

我试过:

NSURL(string: "sms:8888888888,9999999999&body=\(urlSafeBody)")

NSURL(string: "sms:8888888888;9999999999&body=\(urlSafeBody)")

但消息总是显示为仅由第一个数字组成。

感谢任何帮助!

更新: iOS: Launching Messages app with multiple recipients在评论中链接表明 NSURL 中只允许一个收件人。这意味着我正在尝试找出通过 watchkit 发送 SMS 的任何其他方式……不可能吗?

最佳答案

found an obscure page这给了我答案。事实证明,Apple 在我能找到的任何地方都没有记录它:

    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)
     }

上述版本将在 Apple Watch 上打开消息应用程序,并预先填充多个收件人。

许多页面 声明这是不可能的,但它是。万岁!

感谢@petahchristian 提供的链接,它让我沿着谷歌路径找到了这个页面。

更新:为了完整起见 - 这是一个相关问题,我要求从 watch 中获取功能齐全的多收件人预写短信以发送。 AppleWatch Messages URL works hard coded but not with variables

关于ios - SMS WatchKit 多个数字分隔符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36575727/

相关文章:

android - 在我的应用程序中接收短信

ios - swift:nscoding decodeObject 始终为 nil

ios - 具有依赖性的异步任务执行

ios - 使用视差滚动实现 Twitter 配置文件之类的 View

swift - 无法从 `UIStackView` 中删除轴动画

ios - 如何在appdelegate中调用viewController的方法

ios - iOS 10 本地通知(UNNotificationRequest)限制

ios - 如何快速构建具有不同原型(prototype)单元的 UITableViewController

安卓电话号码验证

java - 是否可以通过 Java 中的 GSM 调制解调器发送/接收消息?