How can I open Gmail app from my app(открыть приложение Gmail из своего приложения в свифт) - Swift 5
func openGmailApp(address: String, subject: String, body: String) {
let addressEncoding = address.addingPercentEncoding(withAllowedCharacters: .alphanumerics) ?? ""
let subjectEncoding = subject.addingPercentEncoding(withAllowedCharacters: .alphanumerics) ?? ""
let bodyEncoding = body.addingPercentEncoding(withAllowedCharacters: .alphanumerics) ?? ""
let googleUrlString = "googlegmail:///co?to=\(addressEncoding)&subject=\(subjectEncoding)&body=\(bodyEncoding)"
if let googleUrl = URL(string: googleUrlString) {
UIApplication.shared.open(googleUrl, options: [:]) {
success in
if success {
print("Was found & open app")
}
}
}
else {
print("Could not get URL from string")
}
}
Возврат к списку