Seperate phone number with country code iOS swift || Get only the phone number from iOS swift || How to remove country code while Pick Phone Number from contacts

 Solution:

    The below function will return the phone number if you given with country code and + symbol.Its a default method in iOS.

If you had the phone number with different countries with country code and other formate just pass it as string to the below function and get the original phone number.You don't need any pod files to get that.It's a default method in iOS.

 Before you start the function must import the PhoneNumberKit module to your project.


Code:

import PhoneNumberKit


func phoneNumberParse(phoneNo:String) -> String {


var phNo:String: ""


let phoneNumberKit = PhoneNumberKit()

      do {

          let phoneNumber = try phoneNumberKit.parse(phoneNo)

        phNo  = String(describing:phoneNumber.nationalNumber)

      }

      catch {


}

return phNo

}


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift