有什么方法可以从我的应用程序打开 iMessage 苹果应用程序吗?我不需要任何 Composer ,主要想法是用我的扩展打开实际的 iMessage。
已编辑
我不想发送任何消息;我只需要打开 iMessage App
最佳答案
这可以按如下方式完成(在 Swift 2 中):
let phoneNumber = "958585858"
let text = "Some message"
guard let messageURL = NSURL(string: "sms:\(phoneNumber)&body=\(text)")
else { return }
if UIApplication.sharedApplication().canOpenURL(messageURL) {
UIApplication.sharedApplication().openURL(messageURL)
}
如果您只需要打开消息应用程序:
guard let messageAppURL = NSURL(string: "sms:")
else { return }
if UIApplication.sharedApplication().canOpenURL(messageAppURL) {
UIApplication.sharedApplication().openURL(messageAppURL)
}
确保将 sms:
添加到 Info.plist
中的 LSApplicationQueriesSchemes
关于ios - 从我的应用程序打开 iMessage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40627764/