From 6ce2be4aee866101bd6cc340f418a6493b59d0f0 Mon Sep 17 00:00:00 2001 From: Gregorio Zanon Date: Mon, 10 Jun 2024 10:08:53 +0200 Subject: [PATCH 1/2] Add nickname to name projection on iOS. --- docs/api.md | 32 +++++++++++---------- ios/Plugin/ContactPayload.swift | 1 + ios/Plugin/Contacts.swift | 3 ++ ios/Plugin/CreateContactInput.swift | 2 ++ ios/Plugin/GetContactsProjectionInput.swift | 1 + src/definitions.ts | 2 ++ 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/docs/api.md b/docs/api.md index 8b4530c..424134c 100644 --- a/docs/api.md +++ b/docs/api.md @@ -133,14 +133,15 @@ pickContact(options: PickContactOptions) => Promise #### NamePayload -| Prop | Type | -| ------------- | --------------------------- | -| **`display`** | string \| null | -| **`given`** | string \| null | -| **`middle`** | string \| null | -| **`family`** | string \| null | -| **`prefix`** | string \| null | -| **`suffix`** | string \| null | +| Prop | Type | +| --------------- | --------------------------- | +| **`display`** | string \| null | +| **`given`** | string \| null | +| **`middle`** | string \| null | +| **`family`** | string \| null | +| **`prefix`** | string \| null | +| **`suffix`** | string \| null | +| **`nickname`** | string \| null | #### OrganizationPayload @@ -270,13 +271,14 @@ pickContact(options: PickContactOptions) => Promise #### NameInput -| Prop | Type | -| ------------ | --------------------------- | -| **`given`** | string \| null | -| **`middle`** | string \| null | -| **`family`** | string \| null | -| **`prefix`** | string \| null | -| **`suffix`** | string \| null | +| Prop | Type | +| -------------- | --------------------------- | +| **`given`** | string \| null | +| **`middle`** | string \| null | +| **`family`** | string \| null | +| **`prefix`** | string \| null | +| **`suffix`** | string \| null | +| **`nickname`** | string \| null | #### OrganizationInput diff --git a/ios/Plugin/ContactPayload.swift b/ios/Plugin/ContactPayload.swift index 80d636e..2cf0e8c 100644 --- a/ios/Plugin/ContactPayload.swift +++ b/ios/Plugin/ContactPayload.swift @@ -70,6 +70,7 @@ public class ContactPayload { self.name["family"] = contact.familyName self.name["prefix"] = contact.namePrefix self.name["suffix"] = contact.nameSuffix + self.name["nickname"] = contact.nickname } // Organization diff --git a/ios/Plugin/Contacts.swift b/ios/Plugin/Contacts.swift index 501a3a2..e9a85b0 100644 --- a/ios/Plugin/Contacts.swift +++ b/ios/Plugin/Contacts.swift @@ -120,6 +120,9 @@ public class Contacts: NSObject { if let nameSuffix = contactInput.nameSuffix { newContact.nameSuffix = nameSuffix } + if let nameNickname = contactInput.nameNickname { + newContact.nickname = nameNickname + } // Organization if let organizationName = contactInput.organizationName { diff --git a/ios/Plugin/CreateContactInput.swift b/ios/Plugin/CreateContactInput.swift index 7c54f98..56f4bfd 100644 --- a/ios/Plugin/CreateContactInput.swift +++ b/ios/Plugin/CreateContactInput.swift @@ -9,6 +9,7 @@ public class CreateContactInput { public var nameFamily: String? public var namePrefix: String? public var nameSuffix: String? + public var nameNickname: String? // Organization public var organizationName: String? @@ -44,6 +45,7 @@ public class CreateContactInput { self.nameFamily = nameObject["family"] as? String self.namePrefix = nameObject["prefix"] as? String self.nameSuffix = nameObject["suffix"] as? String + self.nameNickname = nameObject["nickname"] as? String } // Organization diff --git a/ios/Plugin/GetContactsProjectionInput.swift b/ios/Plugin/GetContactsProjectionInput.swift index e86031c..5d3bfa3 100644 --- a/ios/Plugin/GetContactsProjectionInput.swift +++ b/ios/Plugin/GetContactsProjectionInput.swift @@ -70,6 +70,7 @@ public class GetContactsProjectionInput { projection.append(CNContactFamilyNameKey as CNKeyDescriptor) projection.append(CNContactNamePrefixKey as CNKeyDescriptor) projection.append(CNContactNameSuffixKey as CNKeyDescriptor) + projection.append(CNContactNicknameKey as CNKeyDescriptor) } // Organization diff --git a/src/definitions.ts b/src/definitions.ts index 5cd6333..0fbe27a 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -134,6 +134,7 @@ export interface NamePayload { family: string | null; prefix: string | null; suffix: string | null; + nickname: string | null; } export interface OrganizationPayload { @@ -240,6 +241,7 @@ export interface NameInput { family?: string | null; prefix?: string | null; suffix?: string | null; + nickname?: string | null; } export interface OrganizationInput { From ccc8fcdd93d1c53d23b09f30c5ee8a80b389a4cc Mon Sep 17 00:00:00 2001 From: Gregorio Zanon Date: Tue, 11 Jun 2024 09:53:41 +0200 Subject: [PATCH 2/2] Rename nickname to just nick for consistency. --- docs/api.md | 4 ++-- ios/Plugin/ContactPayload.swift | 2 +- ios/Plugin/Contacts.swift | 4 ++-- ios/Plugin/CreateContactInput.swift | 4 ++-- src/definitions.ts | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/api.md b/docs/api.md index 424134c..fa7f516 100644 --- a/docs/api.md +++ b/docs/api.md @@ -141,7 +141,7 @@ pickContact(options: PickContactOptions) => Promise | **`family`** | string \| null | | **`prefix`** | string \| null | | **`suffix`** | string \| null | -| **`nickname`** | string \| null | +| **`nick`** | string \| null | #### OrganizationPayload @@ -278,7 +278,7 @@ pickContact(options: PickContactOptions) => Promise | **`family`** | string \| null | | **`prefix`** | string \| null | | **`suffix`** | string \| null | -| **`nickname`** | string \| null | +| **`nick`** | string \| null | #### OrganizationInput diff --git a/ios/Plugin/ContactPayload.swift b/ios/Plugin/ContactPayload.swift index 2cf0e8c..36b154f 100644 --- a/ios/Plugin/ContactPayload.swift +++ b/ios/Plugin/ContactPayload.swift @@ -70,7 +70,7 @@ public class ContactPayload { self.name["family"] = contact.familyName self.name["prefix"] = contact.namePrefix self.name["suffix"] = contact.nameSuffix - self.name["nickname"] = contact.nickname + self.name["nick"] = contact.nickname } // Organization diff --git a/ios/Plugin/Contacts.swift b/ios/Plugin/Contacts.swift index e9a85b0..5a0b478 100644 --- a/ios/Plugin/Contacts.swift +++ b/ios/Plugin/Contacts.swift @@ -120,8 +120,8 @@ public class Contacts: NSObject { if let nameSuffix = contactInput.nameSuffix { newContact.nameSuffix = nameSuffix } - if let nameNickname = contactInput.nameNickname { - newContact.nickname = nameNickname + if let nameNick = contactInput.nameNick { + newContact.nickname = nameNick } // Organization diff --git a/ios/Plugin/CreateContactInput.swift b/ios/Plugin/CreateContactInput.swift index 56f4bfd..e9615b2 100644 --- a/ios/Plugin/CreateContactInput.swift +++ b/ios/Plugin/CreateContactInput.swift @@ -9,7 +9,7 @@ public class CreateContactInput { public var nameFamily: String? public var namePrefix: String? public var nameSuffix: String? - public var nameNickname: String? + public var nameNick: String? // Organization public var organizationName: String? @@ -45,7 +45,7 @@ public class CreateContactInput { self.nameFamily = nameObject["family"] as? String self.namePrefix = nameObject["prefix"] as? String self.nameSuffix = nameObject["suffix"] as? String - self.nameNickname = nameObject["nickname"] as? String + self.nameNick = nameObject["nick"] as? String } // Organization diff --git a/src/definitions.ts b/src/definitions.ts index 0fbe27a..f760d75 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -134,7 +134,7 @@ export interface NamePayload { family: string | null; prefix: string | null; suffix: string | null; - nickname: string | null; + nick: string | null; } export interface OrganizationPayload { @@ -241,7 +241,7 @@ export interface NameInput { family?: string | null; prefix?: string | null; suffix?: string | null; - nickname?: string | null; + nick?: string | null; } export interface OrganizationInput {