Skip to content

Instantly share code, notes, and snippets.

@modestman
Last active August 13, 2022 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save modestman/ec55a074350cee8d61a066d28912482e to your computer and use it in GitHub Desktop.
Save modestman/ec55a074350cee8d61a066d28912482e to your computer and use it in GitHub Desktop.
Url scheme for compose email with Gmail and Spark
import UIKit
class ViewController: UIViewController {
@IBAction func gmail(_ sender: Any) {
let compose = "googlegmail:///co?subject=Subject&body=some text&to=test@example.com"
.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
let url = URL(string: compose)!
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
}
}
@IBAction func spark(_ sender: Any) {
let compose = "readdle-spark://compose?subject=Subject&body=some text&recipient=test@example.com"
.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
let url = URL(string: compose)!
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
}
}
}
@modestman
Copy link
Author

Необходимо добавить запрашиваемые схемы (googlegmail, readdle-spark) в Info.plist по ключу LSApplicationQueriesSchemes

@CavalcanteLeo
Copy link

is there a way to attach a document into the e-mail?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment