ios - 从我的应用程序打开 iMessage

标签 ios objective-c swift imessage ios-extensions

有什么方法可以从我的应用程序打开 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/

相关文章:

ios - 如何在不重新加载visibleCell的情况下重新加载collectionView上的数据

iphone - UIActivityViewController 报告 "Remote compose controller timed out"

ios - 转换 __bridge CFType 以支持 ARC

ios - 在 RxSwift 中下载一次的正确方法是什么?

ios - 检查 nil 并快速从字典中提取数据

ios - 如何在 iOS 10 上使用 CallKit 显示来电显示(添加标识条目)

ios - 如何创建高度由其标签高度决定的 UITableView header ?

ios - 错误 : property 'frame' not found on object of type 'UIView *'

Objective-C/iPhone 内存管理

ios - GoogleUtilities/AppDelegateSwizzler/Private/GULApplication.h' 文件 > 未找到