I have two VoIP services, one to call in United States and Canada for as much as I want, and one to call internationally. The international service can also be used to call locally, but it charges per minute. On my iPhone, I like to store numbers in international format: +<country> <city> <number>. As in +44 (1632) 960008 for a UK number, where 44 is the country code, 1632 the city code, and 960008 the local number.
I also store my US numbers in that format because I want it to just work when I travel abroad: +1 (646) 555-1234.
In traditional calling, not VoiP, "+" is supposed to be converted to 00. And 00 is supposed to be converted to whatever prefix you asked your operator to associate with 00. This way, you don't have to know the dialling out code specific to the country you are in. In United States, 011 is the dialling out code. Another country may have a single dial out code like United States, or it may have many dial out codes such as 012, 014, 015, 018 with different tariffs for each prefix operator. You have to call customer support and associate one of them with 00 for the + notation to work.
I have discovered that VoIP apps on the iPhone behave differently. Some translate the + to 00. Others just send the + to MySipSwitch. So, I created this simple and ugly dial out plan. It seems to be working. However, I feel that it is not robust enough, and it may fail. I wonder how it can be cleaned up.
If the number starts with *, +, 00, or 011, use the international VoIP. If it starts with +1, 001, or anything else, dial the USA VoIP.
Thank you,
SpookyET
Code: Select all
sys.Log("call from #{req.Header.From.FromURI.ToString()} to #{req.URI.User}.")
if sys.In then
# Do your incoming call processing customisations here.
sys.Dial("#{sys.Username}@local") # Forwards all incoming calls to your registered contacts.
else
# Do your outgoing call processing customisations here.
case req.URI.User
when /^303$/ then sys.Dial("303@sip.blueface.ie") # Blueface speaking clock.
when /^612$/ then sys.Dial("612@fwd.pulver.com") # FWD speaking clock.
when /^\*/ then sys.Dial("International")
when /^\+1/ then sys.Dial("${dst:1}@USA")
when /^\+/ then sys.Dial("011${dst:1}@International")
when /^001/ then sys.Dial("${dst:2}@USA")
when /^011/ then sys.Dial("${dst}@International")
when /^00/ then sys.Dial("011${dst:2}@International")
else sys.Dial("USA")
end
end