how to get ekevent EKparticipant email?
EKParticipant class does not have such a attribute.
Is it possible to render the native ios participants controller t
Category for EKParticipant:
import Foundation
import EventKit
import Contacts
extension EKParticipant {
var email: String? {
// Try to get email from inner property
if respondsToSelector(Selector("emailAddress")), let email = valueForKey("emailAddress") as? String {
return email
}
// Getting info from description
let emailComponents = description.componentsSeparatedByString("email = ")
if emailComponents.count > 1 {
let email = emailComponents[1].componentsSeparatedByString(";")[0]
return email
}
// Getting email from contact
if let contact = (try? CNContactStore().unifiedContactsMatchingPredicate(contactPredicate, keysToFetch: [CNContactEmailAddressesKey]))?.first,
let email = contact.emailAddresses.first?.value as? String {
return email
}
// Getting email from URL
if let email = URL.resourceSpecifier where !email.hasPrefix("/") {
return email
}
return nil
}
}