Можно ли импортировать/экспортировать смс/ммс на Blackberry10?

Можно ли программно импортировать/экспортировать sms/mms на Blackberry10 с помощью каскадного API??


person Taras    schedule 26.02.2013    source источник


Ответы (1)


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

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

            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;`
person Paul Bernhardt    schedule 27.02.2013