我想打开短信应用程序来复制朋友的一些文字.我不是在创建短信.
如何使用Swift代码启动iphone SMS Message应用程序?我在下面看到了这个代码,用于启动Mail应用程序但不能正常工作.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:"]];
我把它改成了,同样没有用
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms:"]];
感谢您的帮助.TIA
Rem*_*Hsu 16
// Swift 3
UIApplication.sharedApplication().openURL(NSURL(string: "sms:")!)
// Swift 4
UIApplication.shared.open(URL(string: "sms:")!, options: [:], completionHandler: nil)
Run Code Online (Sandbox Code Playgroud)
osk*_*rko 15
斯威夫特 5:
let sms: String = "sms:+1234567890&body=Hello Abc How are You I am ios developer."
let strURL: String = sms.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
UIApplication.shared.open(URL.init(string: strURL)!, options: [:], completionHandler: nil)
Run Code Online (Sandbox Code Playgroud)
我不确定您为什么要明确使用短信应用程序,并且我不确定是否可能。另一方面,iOS 默认情况下提供MFMessageComposeViewController从 iOS 应用程序发送短信的功能。
查看此 Swift示例以了解更多详细信息。
编辑: 我找到了这个维基页面,其中可能包含您问题的答案。请注意,我还没有测试过。
let number = "sms:+12345678901"
UIApplication.sharedApplication().openURL(NSURL(string: number)!)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10328 次 |
| 最近记录: |