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
Retired
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Read Inbound & Outbound SMS Messages on BB10 devices

I wrote a knowledge base article about BlackBerry 10 and SMS APIs:

 

http://supportforums.blackberry.com/t5/Native-Development/BlackBerry-10-Developer-s-Guide-to-SMS/ta-...

--------------------------------------------------------------------------------------------
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
Regular Contributor
Posts: 55
Registered: ‎04-04-2012
My Device: BB Device
My Carrier: VZW & ATT

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Thanks

Contributor
Posts: 15
Registered: ‎08-25-2011
My Device: Q10
My Carrier: Vodafone

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Thank you

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

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Please mark my answer with the KB article as the solution if you think it should be. Thanks.

--------------------------------------------------------------------------------------------
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
Developer
Posts: 1,632
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: Read Inbound & Outbound SMS Messages on BB10 devices


mwoolley wrote:

I wrote a knowledge base article about BlackBerry 10 and SMS APIs:

 

http://supportforums.blackberry.com/t5/Native-Development/BlackBerry-10-Developer-s-Guide-to-SMS/ta-...


HI,

 

I'm having a strange problem with my app.  My app can receive sms but if someone sends me text messages larger than 140 chars my app does not recevie the text message.  But if I look at the Text message app it is there and the char count is more than 140 chars.

 

It is because the message is sent as MMS?

 

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

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Which API are you using to receive text messages? Please provide a code fragment that shows your approach.

 

Are you sure 140 is the boundary for this behaviour? 140 *bytes* is the maximum size of an SMS, not 140 characters. The number of characters depends on the character set in use (7 bit or 16 bit UCS2).

 

If you're using the SmsTransport API then generally you should not need to worry about message length with the BlackBerry 10 SMS APIs. A long SMS comprising more than one segment, each preceded by a user data headers, should be concatenated into a single message payload by the underlying messaging system before being passed to an application in the Attachment.data() byte array.

 

If you're using MessageService with the messageAdded and messageUpdated signals, then the messageAdded signal will be emitted when the first 140 byte segment arrives (though you will not get the user data header so the Message object will at this point have a payload less than 140 bytes) and then the messageUpdated signal will be emitted when the next segment arrives. The Message object will at this point have the full concatenated message payload.

 

 

I can't comment on your question about MMS without knowing how the message is being created. Are you saying that it *is* being sent as an MMS? Or are you asking if it is?

 

Does this help? Please mark as solution if it has. Thanks.

 

--------------------------------------------------------------------------------------------
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
Developer
Posts: 1,632
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: Read Inbound & Outbound SMS Messages on BB10 devices

this is my code for the messageAdded() signal.

 

    if (message.isValid() && (message.mimeType() == MimeTypes:Smiley Frustratedms)) 

   {
              QString msg =   message.body(MessageBody:Smiley TonguelainText).plainText();

   }

 

the code never get executed when that type message arrives.

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

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Thanks.

 

Could you please download, install and test with sample application SmsMessageService and let me know the results. 

 

https://github.com/blackberry/Cascades-Community-Samples/blob/master/SmsMessageService/installable-b...

 

What device are you testing with and what OS version?

 

I recommend you use Attachment.data() to access the SMS message payload by the way.

--------------------------------------------------------------------------------------------
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
Developer
Posts: 1,632
Registered: ‎07-14-2008
My Device: Z10
My Carrier: Fido

Re: Read Inbound & Outbound SMS Messages on BB10 devices


mwoolley wrote:

Thanks.

 

Could you please download, install and test with sample application SmsMessageService and let me know the results. 

 

https://github.com/blackberry/Cascades-Community-Samples/blob/master/SmsMessageService/installable-b...

 

What device are you testing with and what OS version?

 

I recommend you use Attachment.data() to access the SMS message payload by the way.


For Attachment.data() does that mean I have to use SmsTransport API?

 

thanks

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

Re: Read Inbound & Outbound SMS Messages on BB10 devices

No, Message objects may have Attachment objects. For example, here's my code which shows this:

 

void SmsMessageService::messageReceived(bb::pim::account::AccountKey account_key, bb::pim::message::ConversationKey conv, bb::pim::message::MessageKey message_key) {

	qDebug() << "XXXX messageReceived";

	Message message = _message_service->message(_sms_account_id, message_key);

	qDebug() << "XXXX Message mime type:" << message.mimeType();
	if (message.mimeType() == MimeTypes::Sms) {
		qDebug() << "XXXX messageReceived: It's an SMS!!!";
		if (message.isInbound()) {
			qDebug() << "XXXX sender:" << message.sender().displayableName();
			if (message.attachmentCount() > 0) {
				showToast("SMS received");
				bb::pim::message::Attachment attachment = message.attachmentAt(0);
				log(QString("RCVD: SMS\n").append("RCVD: from " + message.sender().displayableName()).append("\nRCVD: ").append(QString(attachment.data())));
			} else {
				qDebug() << "XXXX messageReceived: no attachments";
			}
		} else {
			qDebug() << "XXXX messageReceived: not inbound";
		}
	}  else {
		qDebug() << "XXXX messageReceived: not an 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