Fall back to mailto URL when no email account

Useful with third party mail apps.
This commit is contained in:
Davide De Rosa 2019-07-05 11:10:04 +02:00
parent 3a4f262c91
commit 41ed10e76e
4 changed files with 29 additions and 11 deletions

View File

@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## 1.8.0 Beta 1963 (2019-07-05)
## Unreleased
### Added
@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Support third party apps when sending e-mails.
- Refreshed infrastructures are not retained. [core#1](https://github.com/passepartoutvpn/passepartout-core-apple/issues/1)
- Portuguese bound to Brazil region.
- German spelling of "Default gateway".

View File

@ -57,9 +57,16 @@ class IssueReporter: NSObject {
func present(in viewController: UIViewController, withAttachments attachments: Attachments) {
guard MFMailComposeViewController.canSendMail() else {
let alert = Macros.alert(L10n.Core.IssueReporter.title, L10n.Core.Global.emailNotConfigured)
alert.addCancelAction(L10n.Core.Global.ok)
viewController.present(alert, animated: true, completion: nil)
let app = UIApplication.shared
let V = AppConstants.IssueReporter.Email.self
let body = V.body(V.template, DebugLog(raw: "--").decoratedString())
guard let url = Utils.mailto(to: V.recipient, subject: V.subject, body: body), app.canOpenURL(url) else {
let alert = Macros.alert(L10n.Core.IssueReporter.title, L10n.Core.Global.emailNotConfigured)
alert.addCancelAction(L10n.Core.Global.ok)
viewController.present(alert, animated: true, completion: nil)
return
}
app.open(url, options: [:], completionHandler: nil)
return
}

View File

@ -223,17 +223,27 @@ class OrganizerViewController: UITableViewController, TableModelHost {
}
private func offerTranslation() {
let V = AppConstants.Translations.Email.self
let recipient = V.recipient
let subject = V.subject
let body = V.body(V.template)
guard MFMailComposeViewController.canSendMail() else {
let alert = Macros.alert(L10n.Core.IssueReporter.title, L10n.Core.Global.emailNotConfigured)
alert.addCancelAction(L10n.Core.Global.ok)
present(alert, animated: true, completion: nil)
let app = UIApplication.shared
guard let url = Utils.mailto(to: recipient, subject: subject, body: body), app.canOpenURL(url) else {
let alert = Macros.alert(L10n.Core.Translations.title, L10n.Core.Global.emailNotConfigured)
alert.addCancelAction(L10n.Core.Global.ok)
present(alert, animated: true, completion: nil)
return
}
app.open(url, options: [:], completionHandler: nil)
return
}
let vc = MFMailComposeViewController()
vc.setToRecipients([AppConstants.Translations.Email.recipient])
vc.setSubject(AppConstants.Translations.Email.subject)
vc.setMessageBody(AppConstants.Translations.Email.body(AppConstants.Translations.Email.template), isHTML: false)
vc.setToRecipients([recipient])
vc.setSubject(subject)
vc.setMessageBody(body, isHTML: false)
vc.mailComposeDelegate = self
vc.apply(Theme.current)
present(vc, animated: true, completion: nil)

@ -1 +1 @@
Subproject commit 6dd5a4e997f768bf626612dddb7fa321f4899fde
Subproject commit d27010723474d4f0c7fe0199d847b155b5b193c7