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
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10
My Carrier: airtel

How can I get response after send SMS from my application?

I send SMS from my.cpp file but I want to get the response that SMS send successful or not back in my.cpp class.

I use MessageService.

 

messageService.send(accountId, message);

 

Any one can help me?

 

Thanks in advance

Developer
Posts: 86
Registered: ‎05-21-2012
My Device: Blackberry 10 Dev Alpha
My Carrier: IDEA

Re: How can I get response after send SMS from my application?

Hi!

 

      You can use MessageTransmissionStatus class to track the status of the message. Here are the reference urls:

For send method in MessageService:

https://developer.blackberry.com/cascades/reference/bb__pim__message__messageservice.html#function-s...

 

For MessageTransmissionStatus class:

https://developer.blackberry.com/cascades/reference/bb__pim__message__messagetransmissionstatus.html

 

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

Re: How can I get response after send SMS from my application?

Yes I tried it but it's always return 0 & I also try this:

http://developer.blackberry.com/cascades/reference/bb__pim__message__message.html#function-issent

 

In that case message.isSent() return 0 when ever this send success or not.

 

Please help me......

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

Re: How can I get response after send SMS from my application?

bb:Smiley Tongueim::message::MessageService messageService;

bb:Smiley Tongueim::account::AccountService accountService;

 

//Get the SMS/MMS account

QList<Account> accountList = accountService.accounts(Service::Messages,

"sms-mms");

AccountKey accountId = accountList.first().id();

 

// Create a contact to whom you want to send sms/mms.

int contactKey = -1;

bb:Smiley Tongueim::message::MessageContact recipient =

bb:Smiley Tongueim::message::MessageContact(contactKey,

bb:Smiley Tongueim::message::MessageContact::To, contactNumber,

contactNumber);

 

//Create a conversation  because sms/mms chats most of the time is a conversation

bb:Smiley Tongueim::message::ConversationBuilder* conversationBuilder =

bb:Smiley Tongueim::message::ConversationBuilder::create();

conversationBuilder->accountId(accountId);

QList<bb:Smiley Tongueim::message::MessageContact> participants;

participants.append(recipient);

conversationBuilder->participants(participants);

bb:Smiley Tongueim::message::Conversation conversation = *conversationBuilder;

bb:Smiley Tongueim::message::ConversationKey conversationId = messageService.save(

accountId, conversation);

 

//Create a message Builder for sms/mms

bb:Smiley Tongueim::message::MessageBuilder* messageBuilder =

bb:Smiley Tongueim::message::MessageBuilder::create(accountId);

messageBuilder->addRecipient(recipient);

// SMS API's handle body as an attachment.

QString body = regID;

messageBuilder->addAttachment(

bb:Smiley Tongueim::message::Attachment("text/plain", "body.txt", body));

messageBuilder->conversationId(conversationId);

bb:Smiley Tongueim::message::Message message;

message = *messageBuilder;

 

//Sending SMS/MMS

 

//bb::pim::message:Smiley FrustratedmsTransportSendResult:: send (accountId, message );

 

bb:Smiley Tongueim::message::MessageKey key = messageService.send(accountId, message);

// //messageService.setTransmissionStatus(accountId,key,MessageTransmissionStatus:Smiley Happy

QString sKey = QString::number(key);

 

QTextStream out(stdout);

 

out << "SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS";

 

//QTimer::singleShot(10000, this, SLOT(initialloading()));

 

 

out << "kkkkkkkkkkkkkkkkk";

out << message.status();

out << key << "hhhhhhhhhhhhhh";

out << sKey;

 

emit getMessageResponse(sKey);

 

Above code I'm using.But I want to know if the sms sent is sucessfully or is there any failure?

New Contributor
Posts: 5
Registered: ‎07-11-2013
My Device: Z-10
My Carrier: idea

Re: How can I get response after send SMS from my application?

Me too stuck up with the same problem...... Please help

Developer
Posts: 36
Registered: ‎09-09-2014
My Device: BB Passport
My Carrier: T-Mobile Czech republic

Re: How can I get response after send SMS from my application?

Hello, I have problem with checking if sent SMS has been sent OK or not.

 

I have following code in CPP file:

 

...

 //Sending SMS/MMS
   bb:Smiley Tongueim::message::MessageKey key = messageService.send(accountId, message);
    if(message.isSent() && (message.transmissionStatus() ==    bb:Smiley Tongueim::message::MessageTransmissionStatus:Smiley Frustratedent))
            {
                key=1;
            }
            else //if(message.transmissionStatus() ==  bb:Smiley Tongueim::message::MessageTransmissionStatus::FailedToSent)
            {
                key=-1;
            }

 

If I trace values, message.isSent is always false respectively messageTransmissionStatus is always 0 regardless SMs has valid or invalid recipient number.

 

Do not you know what is wrong ?

Developer
Posts: 36
Registered: ‎09-09-2014
My Device: BB Passport
My Carrier: T-Mobile Czech republic

Re: How can I get response after send SMS from my application?

Hello once again, no-one knows where should be the problem with checking if SMS was sent okay or with errors ?

 

Because the lack of this feature there are no possibility to display my app in BB World - but how I can implement requested feature if is not working properly with using given API (I might be mistaken, it's possible that I make something wrong) ?

 

I appreciate any help.

 

Thank you.

 

Karel