MessageInterceptor

V

VicToro

Hi,

I am having problems to use the MessageInterceptor class on a
background app. It worked when I used a device app with a form. But
now, I try to use it in a console app because I want to run it as a
background process.

I have a main class, that is a Console App, that creates a SMSListener
class.
Then the main class calls the start method of the SMSListener:

public void Start()
{
MessageCondition msgCond = new
MessageCondition(MessageProperty.Sender, phoneNumber);
msi = new
MessageInterceptor(InterceptionAction.NotifyAndDelete,false);
msi.MessageCondition = msgCond ;
msi.MessageReceived += new
MessageInterceptorEventHandler(msi_MessageReceived);
}

Suppously when a message if intercepted it executes:

void msi_MessageReceived(object sender,
MessageInterceptorEventArgs e)
{
SmsMessage smsMessage = (SmsMessage)e.Message;
if (smsMessage.Body.StartsWith(keyWord))
{
// process message, show a message Box or any other
action
}
}


If I use a Device App with a Form there is no problem. It intercepts
the message coming from the number "phoneNumber" and process them if
they start with the keyword.

But I am using a Console App in the device, as background process, and
when a message is received from the number "phoneNumber" it displays
as normal message for the phone, and it goes to the Inbox.

Anyone can give a clue?

Cheers,
Victor
 
P

Peter Foot [MVP]

Are you using the overload of the MessageInterceptor constructor which
accepts the boolean argument userFormThread? - you need to set this to false
if using it from a console app.

Peter
 
V

VicToro

It turned out to be that I was using a bad phone number format.

I was using 003538.... and I should use +3538...

It solved the problem of intercepting the message.

I am able to show a message box with the intercepted message.


Cheers,
Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top