Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
smiley
Posts: 1,497
Registered: ‎07-14-2008
My Device: Z10

Re: How listen to SMS and Email?

do i got the Message sample app working.

 

Now how do i check for the new message? If i use this signal it doesn't work

 

    connect(m_messageService, SIGNAL(messageAdded(bb::pim::account::AccountKey, bb::pim::message::ConversationKey, bb::pim::message::MessageKey)), SLOT(filterMessages(bb::pim::message::MessageKey)));

 can I pass the MessageKey to the filterMessages() like above?

 

Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900

Re: How listen to SMS and Email?

There is no way to install the sim card into my Dev Alpha A so that I could not verify SMS messages. Are you using Z10?




p(^_^)q
Good good study, day day up
Developer
smiley
Posts: 1,497
Registered: ‎07-14-2008
My Device: Z10

Re: How listen to SMS and Email?


javayoung wrote:

There is no way to install the sim card into my Dev Alpha A so that I could not verify SMS messages. Are you using Z10?


Yes Z10.  You can installing the leaked OS on your Dev A.   I have the Dev B and have the leaded OS installed but I returned my to BB for the LE exchange.

 

Developer
smiley
Posts: 1,497
Registered: ‎07-14-2008
My Device: Z10

Re: How listen to SMS and Email?

have another big crazy problem.

 

after exiting the message sample app the icon is grey out and can not be deleted or launch.

 

I read in other post about bugs but this is the sample app.  i have not change anything.

 

Running the app on Z10.  anyone have this problem?

Developer
dans
Posts: 20
Registered: ‎11-17-2010
My Device: Dev Alpha A

Re: How listen to SMS and Email?

Interesting, I have seen this too when I was working with it, but I used Bluetooth so I wasn't sure where this was coming from. The App is still running, you can terminate it from the Momentics QNX System Information perspective by sending the SIGTERM signal to the process (right click on the process in the Target Navigator, its in the popup somewhere).
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900

Re: How listen to SMS and Email?

Yes, I actually also met the same bug as yours. Don't worry, it is just a sample. Can all of you verify whether it can listen the SMS message not if you have Z10? Thank you.




p(^_^)q
Good good study, day day up
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900

Re: How listen to SMS and Email?

Lol, there is not the sim card slot on my dev alpha. You are lucky. I just switched to BB10 development from other projects soon, i have not enough time to submit my app. :0(



p(^_^)q
Good good study, day day up
Contributor
jeetak47
Posts: 13
Registered: ‎10-05-2012
My Device: BB 10 dev Alpha

Re: How listen to SMS and Email?

You have to same SLOT signature as SIGNAL so modify you SLOT like

 

filterMessages(bb::pim::account::AccountKey,bb::pim::message::ConversationKey,bb::pim::message::MessageKey)

Developer
KlausNahr
Posts: 45
Registered: ‎07-29-2008
My Device: Z10 Red, 8900, PlayBook

Re: How listen to SMS and Email?

@dans: How did you manage to see SMS in the messages sample? I could not see any SMS, even when I am changing the code and removing the filter or calling messages() instead of searchLocal(). folder() and conversations() return both nothing for the SMS account too.

Klaus Nahr
Developer
KlausNahr
Posts: 45
Registered: ‎07-29-2008
My Device: Z10 Red, 8900, PlayBook

Re: How listen to SMS and Email?

Hi,

 

i fixed the samples app to view and filter SMS/MMS too.

 

At first you have to enable the "Text Messages" Permission in bar-descriptor.xml.

 

In messages.cpp add:

 

#include <bb/pim/message/MessageFilter>

and change filterMessages() to:

 

void Messages::filterMessages()
{
    if (!m_currentAccount.isValid())
        return;

    QList<Message> messages;
    bool isSMS_MMS = m_currentAccount.provider().name() == "sms-mms";

    if (isSMS_MMS  &&  m_filter.isEmpty())
    {
        MessageFilter filter;
        messages = m_messageService->messages(m_currentAccount.id(), filter);
    }
    else
    {
        MessageSearchFilter filter;
        // Use the entered filter string as search value
        filter.addSearchCriteria(SearchFilterCriteria::Any, m_filter);
        messages = m_messageService->searchLocal(m_currentAccount.id(), filter);
    }

    // Clear the old message information from the model
    m_model->clear();

    // Iterate over the list of message IDs
    foreach (const Message &message, messages) {
        // If SMS or MMS show only inbound messages
        if (!isSMS_MMS  ||  message.isInbound())
        {
            // Copy the data into a model entry, for SMS/MMS show Body, otherwise Subject
            QVariantMap entry;
            entry["messageId"] = message.id();
            entry["subject"] = isSMS_MMS ? message.body(MessageBody::smileytongue:lainText).plainText() : message.subject();
            entry["time"] = message.serverTimestamp().toString();

            // Add the entry to the model
            m_model->insert(entry);
        }
    }
}

 

The problem is with searchLocal(). It will not return any SMS/MMS message if the filter is empty. Therefore I am calling messages() if the filter is empty. If you change the SearchFilterCriteria to anything else than Any, the filter does not return any result for SMS/MMS. Seems to be another bug.

 

Inbound and Outbound SMS messages are in one box, thats why I am checking message.isInbound() before adding a SMS message to the list.

 

SMS message do not have a subject, thats why I am showing the body in the list.

Klaus Nahr