views:

450

answers:

5

I would like to know what are the options for intercepting an SMS. I want to be able to launch some code to handle the SMS when it is received. Any advise on whether this is technically possible and what options I have if there is more than one way, would be greatly appreciated.

Thanks Paul

+1  A: 

Since you have so many tags, it's hard to tell which OS you're actually developing for. On the iPhone, you cannot "snoop in" on SMS messages without the help of a patched Kernel (jailbreak).

esqew
We are developing for all those platforms and trying to see if there is a consistent way to do this across many platforms.
+1  A: 

I can speak for Symbian C++ only. And good news - it's possible.
You can use this code example if you want to be notified of all changes in the inbox folder: http://wiki.forum.nokia.com/index.php/CS001416_-_Listening_for_incoming_SMS_messages
Or this example it you want to intercept messages sent to a particular port or only messages that match some text pattern: http://wiki.forum.nokia.com/index.php/SMS_Utilities_API

If you don't want the intercepted message to appear in the inbox folder use the second example.

Yuliya
A: 

At blakberry you also can not spy on SMS messages, which run on standard port.

Nikolay Moskvin
+1  A: 

in blackberry you can attach message listener to specific port.

try {
            final MessageConnection conn = (MessageConnection) Connector.open("sms://:"+port);
            conn.setMessageListener(new MessageListener() {

                public void notifyIncomingMessage(MessageConnection mc) {
                    Message msg;
                    try {
                        msg = conn.receive();
                    } catch (InterruptedIOException ex) {
                        ex.printStackTrace();
                    } catch (IOException ex) {
                        ex.printStackTrace();
                    }
                    String senderAddress = msg.getAddress(); // Get info from message
                    if (msg instanceof TextMessage) {
                        String msgReceived = ((TextMessage) msg).getPayloadText();
                        // Do something with the message here
                    } else if (msg instanceof BinaryMessage) {
                        byte[] msgReceived = ((BinaryMessage) msg).getPayloadData();
                        // do something with the binary message here
                    }
                }
            });

        } catch (IOException ex) {
            ex.printStackTrace();
        }

port=0 means you can listen for all default incoming sms.

if you attach the message listener to port other than 0, message will not appear in inbox. but if you failed to handle this message, it will appear in inbox.

some restrictions are there for message listeners.

  1. you can't read SMS directly from inbox folder.
  2. only one 3rd party application can listen on one port. e.g. if your application is listening on port 0, no other application can listen on this port.
  3. after blackberry restart, blackberry will remove you message listener.
Vivart
+1  A: 

For Windows Mobile it's quite easy to intercept SMS messages using the MessageInterceptor class. MSDN even has an article covering how to use it.

ctacke