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
Contributor
Posts: 10
Registered: ‎01-08-2013
My Device: dev alfa

How to use send simple sms? SmsTransport ?

Hello,

Can someone please help me on how to send simple sms?

maybe using SmsTransport?

I want to do it in C++ or in QML.

 

Contributor
Posts: 10
Registered: ‎01-08-2013
My Device: dev alfa

Re: How to use send simple sms? SmsTransport ?

anyone?

Developer
Posts: 262
Registered: ‎07-13-2012
My Device: PlayBook, DA B, DA C, LE Z10 #102, Q10, Z30

Re: How to use send simple sms? SmsTransport ?

SMS is currently disabled in the DevAlpha build, so no way to really know.  However I had heard that SMS will be available in the SHARE invocation once the full version is deployed (http://bbcascadescode.tumblr.com/post/38998702671/invoke-share-for-bb10).

---
Check out my BB10 Cascades Coding site: BBcascades.com & Cascades Blog: bbcascadescode.tumblr.com

My Built for BlackBerry app: The Dive Plan
Developer
Posts: 18
Registered: ‎04-09-2013
My Device: Z10

Re: How to use send simple sms? SmsTransport ?

I successfully sent a sms to a device using SMs Transport with the following code.

SmsTransportTest::SmsTransportTest(bb::cascades::Application *app) :
		QObject(app) {
	// create scene document from main.qml asset
	// set parent to created document to ensure it exists for the whole application lifetime
	QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);

	// create root object for the UI
	AbstractPane *root = qml->createRootObject<AbstractPane>();
	// set created root object as a scene
	app->setScene(root);
	sendSMS();

}

void SmsTransportTest::portRegistered(unsigned int portNumber,
		bb::pim::message::SmsTransportRegistrationResult::Type resultType) {
	qDebug() << "port registered:" << portNumber;
	qDebug() << "Registered result:" << resultType;
}

void SmsTransportTest::messageReceivedfromPort(unsigned int port, const Message &message)
{
	qDebug() << "Message Received:" << port;
	;
	qDebug() << "message :"<<message.attachmentAt(0).data();

}
void SmsTransportTest::messageSendResultReceived(bb::pim::message::MessageKey msgId)
{
	qDebug() << "message send status" ;

}
void SmsTransportTest::sendSMS() {
	SmsTransport *transport = new SmsTransport();
	bool regPortConnect =
			QObject::connect(transport,
					SIGNAL(registerResultReceived(unsigned int , bb::pim::message::SmsTransportRegistrationResult::Type )),
					this,
					SLOT(portRegistered(unsigned int , bb::pim::message::SmsTransportRegistrationResult::Type )));
	qDebug() << "regPort connect:" << regPortConnect;
	qDebug()<<"------------------------------------------------";
	bool msgReceivd=
			QObject::connect(transport,
								SIGNAL(messageReceived(unsigned int, const Message &)),
								this,
								SLOT(messageReceivedfromPort(unsigned int , const Message &)));

	qDebug() << "message received" << msgReceivd;
	qDebug()<<"------------------------------------------------";
	bool sendResult=
				QObject::connect(transport,
									SIGNAL(messageSendResultReceived(bb::pim::message::MessageKey )),
									this,
									SLOT(messageSendResultReceived(bb::pim::message::MessageKey )));

		qDebug() << "message send result signal :" << sendResult;
		qDebug()<<"------------------------------------------------";

	transport->registerPort(5499);
	AccountService accountService;
	ContactService contactService;
	Account account = accountService.defaultAccount(Service::Messages);
	MessageBuilder* messageBuilder = transport->createMessageBuilder();//MessageBuilder::create(account.id());
	bb::pim::message::MessageContact recipient =
			bb::pim::message::MessageContact(-1,
					bb::pim::message::MessageContact::To,"phNoToSend","phNoToSend");
		QString body="Sending to anutosh,s device";
	messageBuilder->addRecipient(recipient);
	messageBuilder->addAttachment(bb::pim::message::Attachment("text/plain", "", body.toUtf8()));
  	Message newMessage = messageBuilder->body(MessageBody::PlainText,
			QByteArray("This is a test"));
	SmsTransportSendResult::Type sendStatus=transport->send(5499,newMessage);
	qDebug() << "message send status :" << sendStatus;
}

 To receive the message sent in your device should also have the same app running with the port registered.

Developer
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10

Re: How to use send simple sms? SmsTransport ?

Hi Shashadhar,

 

This code works fine for me also . But my requirement is that I want the status of a message which is sent or not . How can I get it? Please help me .....

 

Thanks in advance:smileyhappy:

Developer
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10

Re: How to use send simple SMS? SmsTransport ?

Hi,

 

I am still waiting for your reply please help me.............

 

Thanks in advance.

Developer
Posts: 18
Registered: ‎04-09-2013
My Device: Z10

Re: How to use send simple SMS? SmsTransport ?

[ Edited ]

Hey,

You can get   status of message sent with following code

 

SmsTransportSendResult::Type sendStatus=transport->send(5499,newMessage);
	qDebug() << "message send status :" << sendStatus;
// This will give status of message.
newMessage.transmissionStatus(); //
 newMessage.status();
// see for transmission enum #include <bb/pim/message/MessageTransmissionStatus.hpp

 We may connect to signal  "messageSendResultReceived(bb::smileytongue:im::message::MessageKey msgId)" .

Then get the message using MessageService::messages(msgId,accId) ,can see details in

http://developer.blackberry.com/cascades/reference/bb__pim__message__message.html.

After getting message  just call msg.transmissionstatus which will give status.

 

Thanks!

Developer
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10

Re: How to use send simple SMS? SmsTransport ?

Hi Shashadhar,

 

Thanks for reply . I get the status of the message after send it . Thank you once again for your reply.:smileyhappy:

 

I am using below code in my apps

 

newMessage.transmissionStatus();