2013-02-26 2 views

ответ

2

SMS фактически использует тот же API, что и другие сообщения (например, электронная почта). Главное различие заключается в том, что вы хотите выбрать учетную запись SMS специально, и вы, вероятно, хотите построить, как часть разговора.

Message Используя часть API BlackBerry ПИМ, попробовать что-то вроде этого:

  MessageService messageService; 
      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. Put the right phone number in yourself 
      int contactKey = -1; 
      MessageContact recipient = MessageContact(contactKey, MessageContact::To,"5555555555", "5555555555"); 

      //Create a conversation because sms/mms chats most of the time is a conversation 
      ConversationBuilder* conversationBuilder = ConversationBuilder::create(); 
      conversationBuilder->accountId(accountId); 
      QList<MessageContact> participants; 

      participants.append(recipient); 

      conversationBuilder->participants(participants); 

      Conversation conversation = *conversationBuilder; 
      ConversationKey conversationId = messageService.save(accountId, conversation); 

      //Create a message Builder for sms/mms 
      MessageBuilder* messageBuilder = MessageBuilder::create(accountId); 
      messageBuilder->addRecipient(recipient); 
      // SMS API's handle body as an attachment. 
      QString body = "body of the sms"; 
      messageBuilder->addAttachment(Attachment("text/plain","body.txt",body)); 
      messageBuilder->conversationId(conversationId); 
      Message message; 
      message = *messageBuilder; 

      //Sending SMS/MMS 
      MessageKey key = messageService.send(accountId, message); 
      qDebug() << "+++++++ Message sent" << endl;` 
+0

Спасибо за информацию :) – Taras

Смежные вопросы