BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/)
-   Developer Forum (http://www.blackberryforums.com/developer-forum/)
-   -   IOException when using international access code (+) for sending SMS (http://www.blackberryforums.com/developer-forum/208762-ioexception-when-using-international-access-code-sending-sms.html)

mihaipora 10-28-2009 03:35 PM

IOException when using international access code (+) for sending SMS
 
I have the following code :
Code:

try {
  MessageConnection msgConn = (MessageConnection) Connector.open("sms://" + _receiver + ":9204");
  Message msg = msgConn.newMessage(MessageConnection.BINARY_MESSAGE);
  BinaryMessage binMsg = (BinaryMessage) msg;
  String payload = "test";
  binMsg.setPayloadData(payload.getBytes());
  msgConn.send(binMsg);
  msgConn.close();
  showMessage("Contact SMS sent.");
} catch (SecurityException se) {
  showMessage("SMS blocked by security settings. " + se.getMessage());
} catch (InterruptedIOException e) {
  showMessage("SMS delivery intrerrupted. " + e.getMessage());
} catch (IOException e) {
  showMessage("Error delivering SMS." + e.getMessage());
}

If _receiver contains a phone number without country code (eg : 0744333222) the message is sent .
If _receiver contains a phone number with country code and (+) for international access code like +40744333222 the message is not sent and IOException is raised.
If _receiver contains a phone number with country code and actual local international access code like 0040744333222 the message is sent again with no errors.

This is a very weird behaviour because people sometimes store numbers in full international format because they need them when roaming.

I thought about replacing + with 00, but this is not a general valid solution because some parts of the world use different international acces codes : 00 in Europe, 011 in Unites States and a lot more codes in Asia.

Is there a way to determine the network access code or automatically transform a phone number from the agenda to MSISDN format ?

Any other suggestions are welcome.

Thank you,
Mihai


All times are GMT -5. The time now is 12:35 AM.

Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.