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
nemory
Posts: 217
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10

[HELP] Determine the incoming message if BBM or SMS - MessageService

Hi everyone I badly need your help. I can't figure out a way to know what type of message the phone received.

 

I already have the Signal and Slot messageAdded() and messageUpdated() working. But I need to determine if that message is a BBM or SMS or even Email. Is there a way? Like what BeBuzz does?

Developer
nemory
Posts: 217
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10

Re: [HELP] Determine the incoming message if BBM or SMS - MessageService

void ApplicationUI::onMessageUpdated(bb::pim::account::AccountKey accountId, bb::pim::message::ConversationKey conversationId, bb::pim::message::MessageKey messageId, bb::pim::message::MessageUpdate data)
{
	qDebug() << "TRIGGERED: onMessageUpdated accountId: " << accountId << ", conversationId: " << conversationId << ", messageId: " << messageId;
}

 That's my code for receiving a Message.

 

Developer
cmr1990
Posts: 61
Registered: ‎10-16-2013
My Device: Z10

Re: [HELP] Determine the incoming message if BBM or SMS - MessageService

THis way we could get that the msg is an SMS!
void ApplicationUI::messageReceived(bb::pim::account::AccountKey accKey, bb::pim::message::ConversationKey convoKey, bb::pim::message::MessageKey msgKey) { bb::pim::message::Message message = _messageService->message(_smsAccountId, msgKey); if (message.mimeType() == MimeTypes::Sms) { qDebug() << "Message recieved, its an SMS" ; if (message.isInbound()) { qDebug() << "sender:" << message.sender().displayableName(); } if (message.attachmentCount() > 0) { bb::pim::message::Attachment attachment = message.attachmentAt(0); QString data = "" ; data.append(QString(attachment.data())) ; } else

{

			qDebug() << "messageReceived: no attachments";
		}
		bb::pim::message::MessageContact contact = message.sender() ;
		bb::pim::message::MessageBody body = message.body(MessageBody::PlainText);
	}
}
BlackBerry Development Advisor
RSperanza
Posts: 142
Registered: ‎03-08-2012
My Device: Z10

Re: [HELP] Determine the incoming message if BBM or SMS - MessageService

Hi.

 

Your best bet is to use the AccountService to first loop through all of the accounts and identify the account IDs you need to check for new and / or updated messages.  You can do so first by checking if they support the Message service and then inspect the provider name to see if it is an SMS or e-mail account.  SMS is currently not visible to the Message service.

 

Once you know the account IDs, you check for that ID in the messagesAdded or messagesUpdated signal handler to handle or ignore an incoming signal.  For SMS, you may also need to tap into conversationAdded and conversationUpdated as well.

Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: [HELP] Determine the incoming message if BBM or SMS - MessageService

For information on SMS see http://devblog.blackberry.com/2013/09/blackberry-10-developers-guide-to-sms/

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
BlackBerry Development Advisor
RSperanza
Posts: 142
Registered: ‎03-08-2012
My Device: Z10

Re: [HELP] Determine the incoming message if BBM or SMS - MessageService

My apologies.  I made a typo in my previous reply.   I meant to say that signals for incoming BBM messages are not available at this time.

Developer
nemory
Posts: 217
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10

Re: [HELP] Determine the incoming message if BBM or SMS - MessageService

I've resolved my problem. So much thanks for all the help :smileyhappy:

Developer
10soft
Posts: 33
Registered: ‎12-05-2013
My Device: Z10

Re: [HELP] Determine the incoming message if BBM or SMS - MessageService

Hey Nem, could you share the solution? Never mind if it's confidential :smileyhappy:

 

Thank you.

Developer
ryansweny
Posts: 64
Registered: ‎07-15-2008
My Device: Z10

Re: [HELP] Determine the incoming message if BBM or SMS - MessageService

If the accountId is 13 it is a BBM. Ironically we can read the contents of every private BBM, both incoming and outgoing because they are logged to the file system, but when you try and call msg.isInbound it logs this exception:

 

ErrorInfo in MessageServicePrivate::getItem  Session does not have permission to access the account 13 : 404  methodid  /mail/message  methArgs  0x7d8ecb4  searchParams  0x0

 

Yay security.

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

Re: [HELP] Determine the incoming message if BBM or SMS - MessageService


ryansweny wrote:

If the accountId is 13 it is a BBM. Ironically we can read the contents of every private BBM, both incoming and outgoing because they are logged to the file system, but when you try and call msg.isInbound it logs this exception:

 

ErrorInfo in MessageServicePrivate::getItem  Session does not have permission to access the account 13 : 404  methodid  /mail/message  methArgs  0x7d8ecb4  searchParams  0x0

 

Yay security.


How are you reading the private BBM messages?