gpt4 book ai didi

ios - 在 MFMailComposeViewController 的 messageBody 中查找字符串

转载 作者:行者123 更新时间:2023-11-28 13:34:16 25 4
gpt4 key购买 nike

我已经实现了用户提供反馈的标准方式。当用户点击邮件 View Controller 中的发送或取消时,是否可以通过邮件的消息(或主题)进行搜索。如果邮件包含特定字符串,应用程序应执行操作。在这种情况下不需要发送邮件。谢谢

extension AboutViewController: MFMailComposeViewControllerDelegate {

// MARK: E-Mail

func configureMailComposerViewController() -> MFMailComposeViewController {
let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self

mailComposerVC.setToRecipients(["support@myapp.app"])

let prefix = NSLocalizedString("Feedback", comment: "")
let title = "\(prefix) - myApp v. \(dataModel.appVersion) / iOS \(UIDevice.current.systemVersion) / \(UIDevice.current.deviceModel())"
mailComposerVC.setSubject(title)
let localisedGreeting = NSLocalizedString("Hi", comment: "")
let localisedMessage = NSLocalizedString("I would like to share the following feedback: ", comment: "")
mailComposerVC.setMessageBody("""
\(localisedGreeting),

\(localisedMessage)

""",
isHTML: false)

return mailComposerVC
}

func showSendMailErrorAlert() {
let sendMailErrorAlert = UIAlertController(title: NSLocalizedString("Mail could not be sent", comment: ""),
message: NSLocalizedString("Please check the email configuration in the device settings and try again.", comment: ""),
preferredStyle: .alert)

sendMailErrorAlert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil))

present(sendMailErrorAlert, animated: true, completion: nil)
}

func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {

// Can I get to the message here? I can't find the property of the controller.

dismiss(animated: true, completion: nil)
}

最佳答案

没有可用的公共(public) API 可让您阅读用户电子邮件主题或正文的内容。 MFMailComposeViewControllerDelegate 协议(protocol)仅在用户确实发送电子邮件或决定取消时通知您。

根据文档 here ,您可以在呈现给用户之前自定义电子邮件的字段,但这些字段可以更改。

Before presenting the interface, populate the fields with initial values for the subject, email recipients, body text, and attachments of the email. After presenting the interface, the user can edit your initial values before sending the email.

并且还说用户需要批准电子邮件的内容以及当用户点击发送时发送到邮件应用程序的任何内容。

The composition interface does not guarantee the delivery of your email message; it only lets you construct the initial message and present it for user approval. ... If the user opts to send the message, the message is queued in the user’s Mail app outbox. The Mail app is ultimately responsible for sending the message.

关于ios - 在 MFMailComposeViewController 的 messageBody 中查找字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56883013/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com