Thank you for visiting the BlackBerry Support Community Forums.
BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)
BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.
"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."
- Kevin Michaluk, Founder, CrackBerry.com
Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.
03-07-2013 01:11 PM
I'm trying to connect the messagesAdded signal but it is not firing for QList message.
When I have several messages in my inbox on the server and then I goto the Hub and do a refresh the Hub downloads the messages but the message app signal is not firing.
If there is only one message then the signal fires for that signal but not this signal.
In the messages example app by BlackBerry they have this.
in the .h file
// Filters the messages in the model according to the filter property
in the C++ file
connect(m_messageService, SIGNAL(messagesAdded(bb::pim::account::AccountKey, QList<bb::pim::message::ConversationKey>, QList<bb::pim::message::MessageKey>)), SLOT(filterMessages()));
Solved! Go to Solution.
03-07-2013 07:59 PM
what is it everything so difficult to do and hard to figure out and examples do not work?
since i couldn't get the messagesAdded() signal to work so i tried
ok = connect(m_messageService, SIGNAL(folderSyncCompleted(bb::pim::account::Accou
ntKey, bb::pim::message::MessageFolderKey)), SLOT(folderSyncDone(bb::pim::account::AccountKey, bb::pim::message::MessageFolderKey)));
The connection returns true and yet when i get new messages from the Hub the signal is not fired.
why aren't there more messaging examples. I need help!!
03-07-2013 09:12 PM - edited 03-07-2013 09:27 PM
Well, I played around with that Message Service sample app and found something that might be what you're missing. Not 100% sure but it could be.
In the API description of messagesAdded:
This signal is usually emitted on initial sync or if the server has been out of sync for some time.
When you refresh the Hub, is the app open? According to that description, it should work when you first start the app and the messages are already in the Hub. Don't think you can actually get the 2nd part of the description to happen - where the server is out of sync...
I commented out 3 of the connect functions and left the QList entry there. First attempt I had the app open when refreshing the Hub and the messages weren't retrieved by the app. Second attempt I made sure the app was closed when I refreshed the Hub. Started the app and the messages were retrieved into the app.
This was all on the Simulator btw... I don't have a BB.... yet....
My bad.. I didn't notice the extra filterMessages() right below the connect functions which would actually bring the messages in... doh...
03-07-2013 09:22 PM
thanks for looking into this.
The messages sample app should be running at all times in the "background".
if you send a msg to the account that the message app is set to listen then it should receive the messageAdded() signal. Of course you enter the correct filter. Usually if you use "F" or any letter in the message should work.
You should see the messages listview updated when you do a hub refresh.
This works fine if you send a single message but if you have like 2 or 3 messages the messageAdded() signal won't fire. Reading the doc my assumption was the messagesAdded() signal should fire and give me the list of new msgs with the QList<> var.
In summary: if you send a single message in the account that the message app is listening then it works.
If will NOT work if you have more than one messages on mail server when doing a Hub refresh.
Hope you get what i'm trying to say.
03-07-2013 09:35 PM - edited 03-07-2013 09:42 PM
Yes, I understand what you're saying, but that little key phrase.. initial sync... When does that actually happen?
I think it works for me when I refresh the Hub and have 3 messages there.. They are brought into the app and yes, the app is open when I refreshed.
Nevermind.. Not working.. Tried it again..
03-07-2013 09:43 PM
The message sample app isn't really a good example because of the filtering.
what i'm trying to do is catch new messages coming from the mail server when you do a refresh in the Hub.
I'm not interested in the messages already in the Hub.
if you run the messages app and select an account and set a filter and then send 2 msgs to that account and then do a refresh in the Hub. Those two messages including all the message for that account should show up in the message app.
in the messagesAdded() slot function put a debug in there and see it calls it when you do a fresh in the Hub.
05-09-2013 11:10 AM
Hi, I'm also having the same issue:
When individual messages are received, app detects them and fires the slot.
If I turn off push, and do a manual sync on my emails after I have sent a few test emails, 2 or more are downloaded to the inbox. The app, which is running in the background does nothing.
I looked into it and found I was only doing messageAdded, so I created a new connection using the messagesAdded signal. Same thing happens.
The messages example only seems to refresh when the account is reloaded/reselected, so can't really test that.
I've also looked through the other options in the API and nothing seems to fit the requirement..
Also, its my interpretation that "This signal is usually emitted on initial sync or if the server has been out of sync for some time." is exactly what I'm using it for (not for initial sync, but if the server has been out of sync - which I test by doing a manual refresh).
Only thing I'm wondering is if by me manually refreshing it, for some reason it doesn't trigger.
I'll try and set a sync every x minutes under account settings and see if this works.
Either way, to me it looks like an issue with the API not working correctly.
05-09-2013 11:30 AM
It also does not work when there are queued messages on the server and they are downloaded when the device polls (not manually refreshed).
I've added https://www.blackberry.com/jira/browse/BBTEN-1225 - please vote it up!
05-20-2014 03:05 AM
I had problems connecting the 'messagesAdded' signal too. I got to identify when the signal is launched, but when this happens it was throwing the following error message:
QObject::connect: Cannot queue arguments of type 'QList<bb::pim::message::ConversationKey>' (Make sure 'QList<bb::pim::message::ConversationKey>' is registered using qRegisterMetaType().)
This thread helped me to fix it: http://qt-project.org/forums/viewthread/2884
Adding the following lines I could connect and handle the signal:
In .hpp file: Q_DECLARE_METATYPE(QList<bb::pim::message::Convers
in .cpp file: qRegisterMetaType<QList<bb::pim::message::Conversa
tionKey> >("QList<bb::pim::message::ConversationKey>"); qRegisterMetaType<QList<bb::pim::message::MessageK ey> >("QList<bb::pim::message::MessageKey>"); ... connect(_messageService, SIGNAL(messagesAdded(bb::pim::account::AccountKey, QList<bb::pim::message::ConversationKey>,QList<bb: :pim::message::MessageKey>)), SLOT(onNewMessages(bb::pim::account::AccountKey, QList<bb::pim::message::ConversationKey>,QList<bb: :pim::message::MessageKey>)), Qt::QueuedConnection);
The signal is sent when a new messaging account is added (an email account, for example) or when multiple messages arrive from the server at once. To test the program is more convenient to try the first case, because we have not much control to force the second one.
Hope this will help.
05-20-2014 06:09 AM