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
Regular Contributor
salmanali2074
Posts: 55
Registered: ‎04-04-2012
My Device: BB Device
Accepted Solution

Read Inbound & Outbound SMS Messages on BB10 devices

Hi, 


We have developed an application that is responsible for running in the background and collecting both inbound and outbound text messages for storage on a server. Our customer base has been using our pre-10 version of the application but now we need to support users that are switching to the BB10 OS-based devices. Obviously we are going to develop the new client from scratch.

The new platform offers multiple choices for developing an application. Forums and other support options are severely lacking developer APIs for BB10 development for reading inbound and outbound SMS.

We have looked through the documentation for how our application will start at boot and run in the background completely hidden. None of the API seem to offer this: C++, AIR, Cascades, etc.

In order to support our current customers this capability is a must. I know the QNX operating system supports background daemons, I just have not been able to find any documentation on how to develop that.

How can we develop our application to monitor messages on BB10 devices? 

 

 

Thanks

Retired
bzubert
Posts: 86
Registered: ‎07-11-2008
My Device: Not Specified

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Hi there,

 

The features you're looking for are slated for 10.2.  Check out the feature listed as "headless apps" in the roadmap for the native SDK:

http://developer.blackberry.com/native/downloads/roadmap/

 

There was also a session on the subject of background services at the last BlackBerry Jam event.  This session is available on demand here:

https://bblive.blackberryconferences.net/2013/connect/search.ww#loadSearch-searchPhrase=background&s...

 

Let me know if you have any further questions!

 

Brian Zubert
Technical Partnership Manager
Research In Motion
Retired
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Hi, I recently provided some information on receiving SMS messages that you might find useful. See the following post in these forums:

 

http://supportforums.blackberry.com/t5/Cascades-Development/SMS-Listener/td-p/2434625

 

 

--------------------------------------------------------------------------------------------
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
salmanali2074
Posts: 55
Registered: ‎04-04-2012
My Device: BB Device

Re: Read Inbound & Outbound SMS Messages on BB10 devices

[ Edited ]

Thanks.

That is really helpful.  But I do not see any information about listening (not intercepting) outgoing messages in the post. 

 

Can you capture outgoing SMS too? 

 

 

Salman

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

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Yes, you should be able to do this.

 

The MessageService class has a Qt signal called messageAdded. Connect it to a slot in your code and you should get a call back every time a message is saved in the user's account. When they send an SMS, the system will do that saving automatically.

 

 

Here's some code fragments:

 

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

 

void SmsMessageService::messageReceived(bb::pim::account::AccountKey account_key, bb::pim::message::ConversationKey conv, bb::pim::message::MessageKey message_key) {
	Message message = _message_service->message(_sms_account_id, message_key);

	if (message.attachmentCount() > 0) {
		bb::pim::message::Attachment attachment = message.attachmentAt(0);
		log("RCVD: Message attachment");
		hexlog(attachment.data());
		QVariantMap meta_data = attachment.metaData();
		QList<QString> keys = meta_data.keys();
		QListIterator<QString> i(keys);
		while (i.hasNext()) {
			QString key = i.next();
			QVariant value = meta_data.value(key);
			log(QString("%1=%2").arg(key).arg(value.toString()));
		}
	} else {
		qDebug() << "XXXX messageReceived Message has no attachment";
		MessageBody body = message.body(MessageBody::PlainText);
		log("RCVD: Message received, not an SMS:");
		hexlog(body.data());
	}
	qDebug() << "XXXX end of meta data";

}

 Note that SMS message text is in an Attachment object belonging to the Message object.

 

I'll release a full open source app in github plus KB article on this subject soon!

--------------------------------------------------------------------------------------------
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
salmanali2074
Posts: 55
Registered: ‎04-04-2012
My Device: BB Device

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Thank you and I am looking forward for the github project. 

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

Re: Read Inbound & Outbound SMS Messages on BB10 devices

You're welcome! KB article is progressing well so will do my best to get it and the code out as soon as I can.

 

Cheers

 

Martin

--------------------------------------------------------------------------------------------
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
Contributor
pabloisback
Posts: 15
Registered: ‎08-25-2011
My Device: Q10

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Hello Martin,

For a big project I am working on now, I specifically need to listen for new SMS in our app and to wake the app and offer the user some options.

Looking forward to the KB article and sample project.

Thanks

 

 

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

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Working on it :-)

 

Waking up apps on receipt of an SMS requires the new "headless apps" feature that is coming with 10.2 by the way. At present (10.1) your app must be running in order that it can receive 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
Contributor
pabloisback
Posts: 15
Registered: ‎08-25-2011
My Device: Q10

Re: Read Inbound & Outbound SMS Messages on BB10 devices

Thanks Martin,

In the meantime, can a hyperlink in the sms be clicked to open my app?

 

Is there an option to create a local notification on the phone from receiving a certain SMS (eg in a background service)  - where clicking on the notification can start the app? (it's something I did on other platforms).

 

Otherwise I will report this to the customer they will need to wait for 10.2 for certain features.

Thanks for the reply!