首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用自定义报文打开报文Swift 4

使用自定义报文打开报文Swift 4
EN

Stack Overflow用户
提问于 2018-04-25 12:19:25
回答 3查看 5.4K关注 0票数 3

我想从我的应用程序中打开imessage,并在文本字段中填充“共享我的应用程序...”(底部的消息字段,而不是电话号码字段)

我可以使用下面这行代码从我的应用程序中打开消息:

代码语言:javascript
复制
UIApplication.shared.open(URL(string: "sms:")!, options: [:], completionHandler: nil)

但我不知道如何通过它传递消息。有没有可能不使用MFMessageComposeViewController()来做这件事?我不能使用这个背景播放问题的原因,我正在经历,谢谢你。

EN

回答 3

Stack Overflow用户

发布于 2018-04-25 13:39:15

与@Kuldeep的回复非常相似

代码语言:javascript
复制
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)

似乎为我做到了这一点,感谢Kuldeep对我的帮助;)

票数 12
EN

Stack Overflow用户

发布于 2018-04-25 13:04:53

尝尝这个。

代码语言:javascript
复制
let sms: String = "sms:+1234567890&body=Hello Abc How are You I am ios developer."
UIApplication.shared.open(URL.init(string: sms.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!)!, options: [:], completionHandler: nil)
票数 2
EN

Stack Overflow用户

发布于 2018-04-25 13:13:19

尝试以下步骤在iMessage上发送文本

  1. 在您的按钮操作中实现下面的代码

如果MFMessageComposeViewController.canSendText() { let controller = MFMessageComposeViewController() controller.body = "Your Text here“controller.messageComposeDelegate = self controller.recipients = [] self.present(控制器,动画:真,完成:空)}

  • 实现MFMessageComposeViewControllerDelegate的以下方法

函数控制器(_messageComposeViewController: MFMessageComposeViewController,didFinishWith结果: MessageComposeResult) {controller.dismiss(动画:真,完成:无) }

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50014004

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档