{"id":18303130,"url":"https://github.com/monzo/libphonenumber-ios","last_synced_at":"2025-04-09T10:14:33.829Z","repository":{"id":78418698,"uuid":"577869519","full_name":"monzo/libPhoneNumber-iOS","owner":"monzo","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-14T11:07:27.000Z","size":15066,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-11T08:04:20.548Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Objective-C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/monzo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-13T17:59:32.000Z","updated_at":"2024-05-10T10:48:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"cad1a527-718a-47ab-98b1-e95b489d8a7c","html_url":"https://github.com/monzo/libPhoneNumber-iOS","commit_stats":null,"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monzo%2FlibPhoneNumber-iOS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monzo%2FlibPhoneNumber-iOS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monzo%2FlibPhoneNumber-iOS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monzo%2FlibPhoneNumber-iOS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monzo","download_url":"https://codeload.github.com/monzo/libPhoneNumber-iOS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248018070,"owners_count":21034048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T15:24:17.956Z","updated_at":"2025-04-09T10:14:33.782Z","avatar_url":"https://github.com/monzo.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CocoaPods](https://img.shields.io/cocoapods/p/libPhoneNumber-iOS.svg?style=flat)](http://cocoapods.org/?q=libPhoneNumber-iOS)\n[![CocoaPods](https://img.shields.io/cocoapods/v/libPhoneNumber-iOS.svg?style=flat)](http://cocoapods.org/?q=libPhoneNumber-iOS)\n[![Travis](https://travis-ci.org/iziz/libPhoneNumber-iOS.svg?branch=master)](https://travis-ci.org/iziz/libPhoneNumber-iOS)\n[![Coveralls](https://coveralls.io/repos/iziz/libPhoneNumber-iOS/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/iziz/libPhoneNumber-iOS?branch=master)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n\n# **libPhoneNumber for iOS**\n\n - NBPhoneNumberUtil\n - NBAsYouTypeFormatter\n\n\u003e ARC only\n\n## Update Log\n[https://github.com/iziz/libPhoneNumber-iOS/wiki/Update-Log](https://github.com/iziz/libPhoneNumber-iOS/wiki/Update-Log)\n\n\n## Issue\nYou can check phone number validation using below link.\nhttps://rawgit.com/googlei18n/libphonenumber/master/javascript/i18n/phonenumbers/demo-compiled.html\n\nPlease report, if the above results are different from this iOS library.\nOtherwise, please create issue to following link below to request additional telephone numbers formatting rule.\nhttps://github.com/google/libphonenumber/issues\n\nMetadata in this library was generated from that. so, you should change it first. :)\n\n## Install\n\n### [Swift Package Manager](https://www.swift.org/package-manager/)\n\nAdd Swift Package `https://github.com/monzo/libPhoneNumber-iOS`\nExact version `1.0.3`\n\n## Usage - **NBPhoneNumberUtil**\n```obj-c\n NBPhoneNumberUtil *phoneUtil = [NBPhoneNumberUtil sharedInstance];\n NSError *anError = nil;\n NBPhoneNumber *myNumber = [phoneUtil parse:@\"6766077303\"\n                              defaultRegion:@\"AT\" error:\u0026anError];\n if (anError == nil) {\n     NSLog(@\"isValidPhoneNumber ? [%@]\", [phoneUtil isValidNumber:myNumber] ? @\"YES\":@\"NO\");\n\n     // E164          : +436766077303\n     NSLog(@\"E164          : %@\", [phoneUtil format:myNumber\n                                       numberFormat:NBEPhoneNumberFormatE164\n                                              error:\u0026anError]);\n     // INTERNATIONAL : +43 676 6077303\n     NSLog(@\"INTERNATIONAL : %@\", [phoneUtil format:myNumber\n                                       numberFormat:NBEPhoneNumberFormatINTERNATIONAL\n                                              error:\u0026anError]);\n     // NATIONAL      : 0676 6077303\n     NSLog(@\"NATIONAL      : %@\", [phoneUtil format:myNumber\n                                       numberFormat:NBEPhoneNumberFormatNATIONAL\n                                              error:\u0026anError]);\n     // RFC3966       : tel:+43-676-6077303\n     NSLog(@\"RFC3966       : %@\", [phoneUtil format:myNumber\n                                       numberFormat:NBEPhoneNumberFormatRFC3966\n                                              error:\u0026anError]);\n } else {\n     NSLog(@\"Error : %@\", [anError localizedDescription]);\n }\n\n NSLog (@\"extractCountryCode [%@]\", [phoneUtil extractCountryCode:@\"823213123123\" nationalNumber:nil]);\n\n NSString *nationalNumber = nil;\n NSNumber *countryCode = [phoneUtil extractCountryCode:@\"823213123123\" nationalNumber:\u0026nationalNumber];\n\n NSLog (@\"extractCountryCode [%@] [%@]\", countryCode, nationalNumber);\n```\n##### Output\n```\n2014-07-06 12:39:37.240 libPhoneNumberTest[1581:60b] isValidPhoneNumber ? [YES]\n2014-07-06 12:39:37.242 libPhoneNumberTest[1581:60b] E164          : +436766077303\n2014-07-06 12:39:37.243 libPhoneNumberTest[1581:60b] INTERNATIONAL : +43 676 6077303\n2014-07-06 12:39:37.243 libPhoneNumberTest[1581:60b] NATIONAL      : 0676 6077303\n2014-07-06 12:39:37.244 libPhoneNumberTest[1581:60b] RFC3966       : tel:+43-676-6077303\n2014-07-06 12:39:37.244 libPhoneNumberTest[1581:60b] extractCountryCode [82]\n2014-07-06 12:39:37.245 libPhoneNumberTest[1581:60b] extractCountryCode [82] [3213123123]\n```\n\n#### with Swift\n##### Case (1) with Framework\n```\nimport libPhoneNumberiOS\n```\n\n##### Case (2) with Bridging-Header\n```obj-c\n// Manually added\n#import \"NBPhoneNumberUtil.h\"\n#import \"NBPhoneNumber.h\"\n\n// CocoaPods (check your library path)\n#import \"libPhoneNumber_iOS/NBPhoneNumberUtil.h\"\n#import \"libPhoneNumber_iOS/NBPhoneNumber.h\"\n\n// add more if you want...\n```\n\n##### Case (3) with CocoaPods\nimport libPhoneNumber_iOS\n\n\n##### - in swift class file\n###### 2.x\n```swift\noverride func viewDidLoad() {\n    super.viewDidLoad()\n\n    guard let phoneUtil = NBPhoneNumberUtil.sharedInstance() else {\n        return\n    }\n\n    do {\n        let phoneNumber: NBPhoneNumber = try phoneUtil.parse(\"01065431234\", defaultRegion: \"KR\")\n        let formattedString: String = try phoneUtil.format(phoneNumber, numberFormat: .E164)\n\n        NSLog(\"[%@]\", formattedString)\n    }\n    catch let error as NSError {\n        print(error.localizedDescription)\n    }\n}\n```\n\n## Usage - **NBAsYouTypeFormatter**\n```obj-c\n NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@\"US\"];\n    NSLog(@\"%@\", [f inputDigit:@\"6\"]); // \"6\"\n    NSLog(@\"%@\", [f inputDigit:@\"5\"]); // \"65\"\n    NSLog(@\"%@\", [f inputDigit:@\"0\"]); // \"650\"\n    NSLog(@\"%@\", [f inputDigit:@\"2\"]); // \"650 2\"\n    NSLog(@\"%@\", [f inputDigit:@\"5\"]); // \"650 25\"\n    NSLog(@\"%@\", [f inputDigit:@\"3\"]); // \"650 253\"\n\n    // Note this is how a US local number (without area code) should be formatted.\n    NSLog(@\"%@\", [f inputDigit:@\"2\"]); // \"650 2532\"\n    NSLog(@\"%@\", [f inputDigit:@\"2\"]); // \"650 253 22\"\n    NSLog(@\"%@\", [f inputDigit:@\"2\"]); // \"650 253 222\"\n    NSLog(@\"%@\", [f inputDigit:@\"2\"]); // \"650 253 2222\"\n    // Can remove last digit\n    NSLog(@\"%@\", [f removeLastDigit]); // \"650 253 222\"\n\n    NSLog(@\"%@\", [f inputString:@\"16502532222\"]); // 1 650 253 2222\n```\n\n## libPhoneNumberGeocoding\n\nFor more information on libPhoneNumberGeocoding and its usage, please visit [libPhoneNumberGeocoding](https://github.com/iziz/libPhoneNumber-iOS/blob/master/libPhoneNumberGeocoding/README.md) for more information.\n\n## libPhoneNumberShortNumber\n\nFor more information on libPhoneNumberShortNumber and its usage, please visit [libPhoneNumberShortNumber](https://github.com/iziz/libPhoneNumber-iOS/blob/master/libPhoneNumberShortNumber/README.md) for more information.\n\n##### Visit [libphonenumber](https://github.com/google/libphonenumber) for more information or mail (zen.isis@gmail.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonzo%2Flibphonenumber-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonzo%2Flibphonenumber-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonzo%2Flibphonenumber-ios/lists"}