Skip to content

Library has wrong assumptions for "CNContactsUserDefaults.shared().countryCode.uppercased()" on macOS #845

@xhruso00

Description

@xhruso00

The value of CNContactsUserDefaults.shared().countryCode.uppercased() is actually address format, not the current region user has set on macOS. On top if user deletes default value or has been upgrading from old macOS version it will have legacy values which cause the korean bug....
This was already mentioned before in #694

Image

// macCatalyst OS bug if language is set to Korean

            // macCatalyst OS bug if language is set to Korean
            // CNContactsUserDefaults.shared().countryCode will return ko instead of kr
            // Failed parsing any phone number.
            let countryCode = CNContactsUserDefaults.shared().countryCode.uppercased()
import Contacts

let locale = Locale.current
locale.language
locale.region
let countryCode = CNContactsUserDefaults.shared().countryCode.uppercased()
print(countryCode)

This will print SK and SN (region Slovakia but address format Senegal)

New Issue Checklist

  • [x ] Updated PhoneNumberKit to the latest version
  • Phone number formatted correctly on JavaScript version
  • I searched for existing GitHub issues
  • I am aware that this library is not responsible of adding/removing/changing phone number formats and any request should be done at libphonenumber repo

Steps to reproduce

Expected result
Actual result

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions