Erlang driver for libphonenumber.
- This project is actively maintained, with frequent updates due to the original author's inactivity.
- Compatible with both
rebar
andrebar3
, as well ashex
. - To change the
libphonenumber
version, modify theDRIVER_REV
argument inrebar.config
. - By default, the build uses a git tag archive rather than a full clone and tag checkout. You can change this behavior by modifying the
DRIVER_SRC
argument inrebar.config
.
Ensure all dependencies needed to build libphonenumber
are installed. Below is a summary for each operating system where the library has been tested. If you encounter issues, consult the libphonenumber documentation for additional guidance.
For the latest versions, run:
sudo apt-get install cmake cmake-curses-gui libicu-dev
sudo apt-get install libprotobuf-dev protobuf-compiler
Enable EPEL (required for RE2):
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Then install the required packages:
sudo yum install cmake git libicu-devel protobuf-devel protobuf-compiler
Make sure you have brew
installed. Rebar will automatically install all necessary dependencies.
You can use ccache
to speed up the compilation:
- Install
ccache
on your platform (e.g.,sudo apt-get install ccache
for Debian-based systems orbrew install ccache
for macOS). - In
rebar.config.script
, add:
os:putenv("ELIBPHONENUMBER_USE_CCACHE", "1"),
Config.
Ensure the application is started, then use the phonenumber_to_carrier:carrier_for_number/2
method:
application:ensure_all_started(elibphonenumber).
phonenumber_to_carrier:carrier_for_number(<<"44743655551">>, <<"en">>).
To retrieve the timezones associated with a number, call phonenumber_to_timezones:timezones_for_number/1
as follows:
application:ensure_all_started(elibphonenumber).
phonenumber_to_timezones:timezones_for_number(<<"16502530000">>).
{ok,[<<"America/Los_Angeles">>]}
To get the geographical area of a phone number (if available), use the following method:
application:ensure_all_started(elibphonenumber).
phonenumber_geocoding:get_geocoding_for_number(<<"+16502530000">>),
<<"Mountain View, CA">>
rebar3 eunit