All Projects → iziz → Libphonenumber Ios

iziz / Libphonenumber Ios

Licence: apache-2.0
iOS port from libphonenumber (Google's phone number handling library)

Programming Languages

objective c
16641 projects - #2 most used programming language
c
50402 projects - #5 most used programming language
swift
15916 projects

Projects that are alternatives of or similar to Libphonenumber Ios

Hxphotopicker
图片/视频选择器 - 支持LivePhoto、GIF图片选择、3DTouch预览、在线下载iCloud上的资源、编辑图片/视频、浏览网络图片 功能 Imitation wx photo/image picker - support for LivePhoto, GIF image selection, 3DTouch preview, Download the resources on iCloud online, browse the web image function
Stars: ✭ 2,363 (+3.96%)
Mutual labels:  cocoapods
Smileviewcontroller
UIViewController which allows to detect smile in real time.
Stars: ✭ 189 (-91.68%)
Mutual labels:  cocoapods
Cltypinglabel
iOS UILabel with character by character typing /typewriter animation
Stars: ✭ 192 (-91.55%)
Mutual labels:  cocoapods
Emalertcontroller
EMAlertController is a beautiful alternative to the stock iOS UIAlertController
Stars: ✭ 182 (-91.99%)
Mutual labels:  cocoapods
Cocoapods Generate
A CocoaPods plugin that allows you to easily generate a workspace from a podspec.
Stars: ✭ 187 (-91.77%)
Mutual labels:  cocoapods
Cognitive Face Ios
iOS SDK for the Microsoft Face API, part of Cognitive Services
Stars: ✭ 191 (-91.6%)
Mutual labels:  cocoapods
L10n Swift
Localization of the application with ability to change language "on the fly" and support for plural form in any language.
Stars: ✭ 177 (-92.21%)
Mutual labels:  cocoapods
Imagetransition
Library for smooth animation of images during transitions.
Stars: ✭ 195 (-91.42%)
Mutual labels:  cocoapods
Displayswitcher
Custom transition between two collection view layouts
Stars: ✭ 2,253 (-0.88%)
Mutual labels:  cocoapods
Podtobuild
An easy way to integrate CocoaPods into Bazel
Stars: ✭ 193 (-91.51%)
Mutual labels:  cocoapods
Collor
A declarative-ui framework for UICollectionView with great and useful features.
Stars: ✭ 182 (-91.99%)
Mutual labels:  cocoapods
M3u8parser
A light weight M3U8 parser. Support X-Key & X-Session-Key.
Stars: ✭ 187 (-91.77%)
Mutual labels:  cocoapods
Whatsnewkit
Showcase your awesome new app features 📱
Stars: ✭ 2,329 (+2.46%)
Mutual labels:  cocoapods
Glinapppurchase
Tinder Style InApp Purchase Banner
Stars: ✭ 180 (-92.08%)
Mutual labels:  cocoapods
Bostring
Create NSAttributedString like a boss!
Stars: ✭ 193 (-91.51%)
Mutual labels:  cocoapods
Modernavplayer
ModernAVPlayer is a persistence AVPlayer wrapper
Stars: ✭ 179 (-92.12%)
Mutual labels:  cocoapods
Pull To Refresh.rentals Ios
This project aims to provide a simple and customizable pull to refresh implementation. Made in Yalantis
Stars: ✭ 2,171 (-4.49%)
Mutual labels:  cocoapods
Segmentio
Animated top/bottom segmented control written in Swift.
Stars: ✭ 2,310 (+1.63%)
Mutual labels:  cocoapods
Swiftyanimate
Composable animations in Swift
Stars: ✭ 194 (-91.47%)
Mutual labels:  cocoapods
Ios Modular Architecture
Template iOS application using Modular Architecture
Stars: ✭ 190 (-91.64%)
Mutual labels:  cocoapods

CocoaPods CocoaPods Travis Coveralls Carthage compatible

libPhoneNumber for iOS

  • NBPhoneNumberUtil
  • NBAsYouTypeFormatter

ARC only

Update Log

https://github.com/iziz/libPhoneNumber-iOS/wiki/Update-Log

Issue

You can check phone number validation using below link. https://rawgit.com/googlei18n/libphonenumber/master/javascript/i18n/phonenumbers/demo-compiled.html

Please report, if the above results are different from this iOS library. Otherwise, please create issue to following link below to request additional telephone numbers formatting rule. https://github.com/google/libphonenumber/issues

Metadata in this library was generated from that. so, you should change it first. :)

Install

Using CocoaPods

source 'https://github.com/CocoaPods/Specs.git'
pod 'libPhoneNumber-iOS', '~> 0.8'
Installing libPhoneNumber Geocoding Features
pod 'libPhoneNumberGeocoding', :git => 'https://github.com/CocoaPods/Specs.git'

Using Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate libPhoneNumber into your Xcode project using Carthage, specify it in your Cartfile:

github "iziz/libPhoneNumber-iOS"

And set the Embedded Content Contains Swift to "Yes" in your build settings.

Setting up manually

Add source files to your projects from libPhoneNumber - Add "CoreTelephony.framework"

See sample test code from

[libPhoneNumber-iOS/libPhoneNumberTests/ ... Test.m] (https://github.com/iziz/libPhoneNumber-iOS/tree/master/libPhoneNumberTests)

Usage - NBPhoneNumberUtil

 NBPhoneNumberUtil *phoneUtil = [NBPhoneNumberUtil sharedInstance];
 NSError *anError = nil;
 NBPhoneNumber *myNumber = [phoneUtil parse:@"6766077303"
                              defaultRegion:@"AT" error:&anError];
 if (anError == nil) {
     NSLog(@"isValidPhoneNumber ? [%@]", [phoneUtil isValidNumber:myNumber] ? @"YES":@"NO");

     // E164          : +436766077303
     NSLog(@"E164          : %@", [phoneUtil format:myNumber
                                       numberFormat:NBEPhoneNumberFormatE164
                                              error:&anError]);
     // INTERNATIONAL : +43 676 6077303
     NSLog(@"INTERNATIONAL : %@", [phoneUtil format:myNumber
                                       numberFormat:NBEPhoneNumberFormatINTERNATIONAL
                                              error:&anError]);
     // NATIONAL      : 0676 6077303
     NSLog(@"NATIONAL      : %@", [phoneUtil format:myNumber
                                       numberFormat:NBEPhoneNumberFormatNATIONAL
                                              error:&anError]);
     // RFC3966       : tel:+43-676-6077303
     NSLog(@"RFC3966       : %@", [phoneUtil format:myNumber
                                       numberFormat:NBEPhoneNumberFormatRFC3966
                                              error:&anError]);
 } else {
     NSLog(@"Error : %@", [anError localizedDescription]);
 }

 NSLog (@"extractCountryCode [%@]", [phoneUtil extractCountryCode:@"823213123123" nationalNumber:nil]);

 NSString *nationalNumber = nil;
 NSNumber *countryCode = [phoneUtil extractCountryCode:@"823213123123" nationalNumber:&nationalNumber];

 NSLog (@"extractCountryCode [%@] [%@]", countryCode, nationalNumber);
Output
2014-07-06 12:39:37.240 libPhoneNumberTest[1581:60b] isValidPhoneNumber ? [YES]
2014-07-06 12:39:37.242 libPhoneNumberTest[1581:60b] E164          : +436766077303
2014-07-06 12:39:37.243 libPhoneNumberTest[1581:60b] INTERNATIONAL : +43 676 6077303
2014-07-06 12:39:37.243 libPhoneNumberTest[1581:60b] NATIONAL      : 0676 6077303
2014-07-06 12:39:37.244 libPhoneNumberTest[1581:60b] RFC3966       : tel:+43-676-6077303
2014-07-06 12:39:37.244 libPhoneNumberTest[1581:60b] extractCountryCode [82]
2014-07-06 12:39:37.245 libPhoneNumberTest[1581:60b] extractCountryCode [82] [3213123123]

with Swift

Case (1) with Framework
import libPhoneNumberiOS
Case (2) with Bridging-Header
// Manually added
#import "NBPhoneNumberUtil.h"
#import "NBPhoneNumber.h"

// CocoaPods (check your library path)
#import "libPhoneNumber_iOS/NBPhoneNumberUtil.h"
#import "libPhoneNumber_iOS/NBPhoneNumber.h"

// add more if you want...
Case (3) with CocoaPods

import libPhoneNumber_iOS

- in swift class file
2.x
override func viewDidLoad() {
    super.viewDidLoad()

    guard let phoneUtil = NBPhoneNumberUtil.sharedInstance() else {
        return
    }

    do {
        let phoneNumber: NBPhoneNumber = try phoneUtil.parse("01065431234", defaultRegion: "KR")
        let formattedString: String = try phoneUtil.format(phoneNumber, numberFormat: .E164)

        NSLog("[%@]", formattedString)
    }
    catch let error as NSError {
        print(error.localizedDescription)
    }
}

Usage - NBAsYouTypeFormatter

 NBAsYouTypeFormatter *f = [[NBAsYouTypeFormatter alloc] initWithRegionCode:@"US"];
    NSLog(@"%@", [f inputDigit:@"6"]); // "6"
    NSLog(@"%@", [f inputDigit:@"5"]); // "65"
    NSLog(@"%@", [f inputDigit:@"0"]); // "650"
    NSLog(@"%@", [f inputDigit:@"2"]); // "650 2"
    NSLog(@"%@", [f inputDigit:@"5"]); // "650 25"
    NSLog(@"%@", [f inputDigit:@"3"]); // "650 253"

    // Note this is how a US local number (without area code) should be formatted.
    NSLog(@"%@", [f inputDigit:@"2"]); // "650 2532"
    NSLog(@"%@", [f inputDigit:@"2"]); // "650 253 22"
    NSLog(@"%@", [f inputDigit:@"2"]); // "650 253 222"
    NSLog(@"%@", [f inputDigit:@"2"]); // "650 253 2222"
    // Can remove last digit
    NSLog(@"%@", [f removeLastDigit]); // "650 253 222"

    NSLog(@"%@", [f inputString:@"16502532222"]); // 1 650 253 2222

libPhoneNumberGeocoding

For more information on libPhoneNumberGeocoding and its usage, please visit libPhoneNumberGeocoding for more information.

libPhoneNumberShortNumber

For more information on libPhoneNumberShortNumber and its usage, please visit libPhoneNumberShortNumber for more information.

Visit libphonenumber for more information or mail ([email protected])
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].