Skip to content

Commit

Permalink
Merge branch 'studio-terra-fix/missing-birthday-and-organizationName'…
Browse files Browse the repository at this point in the history
… into develop
  • Loading branch information
Idrimi committed Jan 25, 2021
2 parents d308d90 + 8df9582 commit 8d6cd07
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ios/Plugin/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,26 @@ public class ContactsPlugin: CAPPlugin {
"address": emailToAppend
])
}
let dateFormatter = DateFormatter()
// You must set the time zone from your default time zone to UTC +0,
// which is what birthdays in Contacts are set to.
dateFormatter.timeZone = TimeZone(identifier: "UTC")
dateFormatter.dateFormat = "YYYY-MM-dd"

var contactResult: PluginResultData = [
"contactId": contact.identifier,
"displayName": "\(contact.givenName) \(contact.familyName)",
"phoneNumbers": phoneNumbers,
"emails": emails
"emails": emails,
]
if let photoThumbnail = contact.thumbnailImageData {
contactResult["photoThumbnail"] = "data:image/png;base64,\(photoThumbnail.base64EncodedString())"
if let birthday = contact.birthday?.date {
contactResult["birthday"] = dateFormatter.string(from: birthday)
}
if !contact.organizationName.isEmpty {
contactResult["organizationName"] = contact.organizationName
contactResult["organizationRole"] = contact.jobTitle
}
contactsArray.append(contactResult)
}
Expand Down
3 changes: 3 additions & 0 deletions ios/Plugin/class/Contacts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class Contacts {
CNContactFamilyNameKey,
CNContactEmailAddressesKey,
CNContactThumbnailImageDataKey,
CNContactBirthdayKey,
CNContactOrganizationNameKey,
CNContactJobTitleKey,
] as [Any]

//Get all the containers
Expand Down

0 comments on commit 8d6cd07

Please sign in to comment.