16 Replies Latest reply: Sep 3, 2013 5:58 AM by mwoolley RSS

Not getting Message Received Signal

pushkaraj9009 Novice

Hello,

I am trying to develop an message application in cascades..I tried using SMS Transport API for this..But im not getting the OnReceived Signal for message received...

Also tried using following code

SMS Listener

 

But still the same issue occurs...My port gets registered successfully but dont get the signal for message received..

 

Please help...

 

Thanks

  • Re: Not getting Message Received Signal
    mwoolley Apprentice

    OK that's the problem then. If you wish to receive messages addressed to port 16000 then you need to send them to port 16000. If you do not, then change your app to register on port 0 and hopefully it will fire the signal when a message arrives.

  • Re: Not getting Message Received Signal
    mwoolley Apprentice

    Hi

     

    there's an error in your connect statement. You should only specify the types of the arguments and not their names:

     

    Notice you have specified the name of "port" here:

    connect(_sms_transport, SIGNAL(messageReceived(unsigned int port,
          const bb::pim::message::Message &)), this,
          SLOT(onMessageReceived(unsigned int port,  const bb::pim::message::Message &)));*/

     

    Here's my example from the BlackBerry 10 Developer's Guide to Developers (BlackBerry 10 Developer’s Guide to SMS and MMS) :

     

     connect(_sms_transport, 
                      SIGNAL(messageReceived (
                               unsigned int, 
                               const Message &)), 
                   this, 
                      SLOT(onMessageReceived(
                             unsigned int, 
                             const Message &)));
  • Re: Not getting Message Received Signal
    pushkaraj9009 Novice

    Thanks sir...the user directed message example worked for me...Smiley Happy

  • Re: Not getting Message Received Signal
    mwoolley Apprentice

    OK then you're dealing with "user directed SMS" and the SmsMessageService app will show you how to do this. Your application will need to be running for this to work however. The new headless applications capability that was released with 10.2.0 has SMS triggers but unfortunately they will not work in your case as they are designed for use cases involving non-zero port numbers (normally used to transport binary data).

     

    http://developer.blackberry.com/native/documentation/core/headless_invoke.html

     

    If you think I have you on the right track now, please mark one of my responses as "Solved". Thanks.

  • Re: Not getting Message Received Signal
    mwoolley Apprentice

    The signal is actually called messageReceived not onReceived. Make sure you have the name and argument list right in your connect statement. Look in the log for errors indicating problems with the connect statement.

     

    Also, see the BlackBerry 10 Developer's Guide to SMS:

    BlackBerry 10 Developer’s Guide to SMS and MMS

     

    regards

     

    Martin

    • Re: Not getting Message Received Signal
      pushkaraj9009 Novice

      sorry i mean the same messageReceived Signal...I have used it properly with correct arguments...Im not getting any errors in log too..still the signal is not emmitted when there is a new message in my inbox...

      This is what i have tried

       

      #include "SmsApp.hpp"
      
      #include <bb/cascades/Application>
      #include <bb/cascades/QmlDocument>
      #include <bb/cascades/AbstractPane>
      #include <bb/system/SystemToast>
      #include <bb/pim/message/ConversationBuilder>
      #include <bb/pim/message/MessageBuilder>
      #include <bb/pim/message/MessageService>
      #include <bb/pim/message/MessageContact>
      #include <bb/pim/account/AccountService>
      #include <bb/cascades/Page>
      #include <QSettings>
      
      using namespace bb::cascades;
      using namespace bb::pim::account;
      using namespace bb::pim::message;
      
      SmsApp::SmsApp(bb::cascades::Application *app)
      : QObject(app),
      _sms_transport(new bb::pim::message::SmsTransport(this))
      {
          // create scene document from main.qml asset
          // set parent to created document to ensure it exists for the whole application lifetime
          QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
      
      
      
          connect(_sms_transport, SIGNAL(messageReceived (unsigned int, const Message &)), this,
                         SLOT(onMessageReceived(unsigned int, const Message &)));
      
          connect(_sms_transport, SIGNAL(registerResultReceived(unsigned int,
            bb::pim::message::SmsTransportRegistrationResult::Type)), this,
            SLOT(onRegisterResultReceived(unsigned int,
              bb::pim::message::SmsTransportRegistrationResult::Type)));
      /*
          connect(_sms_transport, SIGNAL(messageReceived(unsigned int port,
            const bb::pim::message::Message &)), this,
            SLOT(onMessageReceived(unsigned int port,  const bb::pim::message::Message &)));*/
      
          _sms_transport->registerPort(16000);
      
          qml->setContextProperty("_smsexample", this);
      
          // create root object for the UI
          AbstractPane *root = qml->createRootObject<AbstractPane>();
          // set created root object as a scene
          app->setScene(root);
      }
      
      
      void SmsApp::onRegisterResultReceived(unsigned int port,
        bb::pim::message::SmsTransportRegistrationResult::Type status)
      {
       if(status == 1)
       {
        qDebug()<<"Port registered succesfully";
       }
       else
       {
        qDebug()<<"Port not registered succesfully";
       }
      
      }
      
      void SmsApp::onMessageReceived(unsigned int port, const Message& message)
      {
      
       qDebug()<<"Message received succesfully";
       bb::pim::message::Attachment attachment = message.attachmentAt(0);
       qDebug()<<attachment.data();
      }
  • Re: Not getting Message Received Signal
    mwoolley Apprentice

    OK I think I just spotted the issue. You have registered on port 16000. Messages sent to port 16000 will not go into the inbox. So if you are seeing your test message go into the inbox that means you are not addressing it to port 16000.

     

    The BlackBerry 10 Developer's Guide to SMS explains all of this and has two full sample applications which I think should help you both develop and trouble shoot issues.

     

    BlackBerry 10 Developer’s Guide to SMS and MMS

     

    So are you using the standard user text messaging application to send your test message or did you write a special application for this purposes?

  • Re: Not getting Message Received Signal
    pushkaraj9009 Novice

    Im sending messages from another device to my device..Is it the wrong way to expect the messagereceived signal to get emmited when we get a new message in our inbox...