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
peevedoffdeveloper
Posts: 35
Registered: ‎03-04-2013
My Device: 9850

Share text message and email with subject.

Does anyone know how to share a text message like the way RIM is doing it with the app world app with the share action when looking at an app? I can invoke the invoke the sheet with the list of all the matching sources for the query however for email I would like to include a subject as well just like how it works in the app world app.

 

For text messages and bbm just get the body and email gets body and subject.

 

Right now I am using 

 

mimeType: "text/plain"

invokeActionId: "bb.action.share"

 

this is retrieving the correct results from the query.

 

but how to set the data.

 

I am just passing a text message like

data = "my text message"

 

should I be using a json string like this

 

{
  "subject": "Some punctuation. Symbol",
  "body" : "HI! Here is some more stuff."
}
Developer
mdodd
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 LE

Re: Share text message and email with subject.

[ Edited ]

I personally took the mailto: URI approach, though I think a JSON string can work just as well. Here's how I invoke a new email with the subject automatically filled in.

 

// Prepare the invocation
bb::system::InvokeManager invokeManager;
bb::system::InvokeRequest request;

// Generate the email
request.setTarget("sys.pim.uib.email.hybridcomposer");
request.setAction("bb.action.OPEN");
request.setUri(QUrl("mailto:email@domain.com?subject=Email%20Subject"));


// Perform the invoke
InvokeTargetReply* invokeReply = invokeManager.invoke(request);

if(invokeReply) {
	invokeReply->setParent(this);
	connect(invokeReply, SIGNAL(finished()), this, SLOT(onInvokeResult()));
	mReply = invokeReply;
}

 

EDIT: Here's the documentation



Did this post help you? If so, please make sure to "like" it!
Contributor
peevedoffdeveloper
Posts: 35
Registered: ‎03-04-2013
My Device: 9850

Re: Share text message and email with subject.

When I use this as data

 

{
  "subject": "Some punctuation. Symbol",
  "body" : "HI! Here is some more stuff."
}
 
It will just try to send this as a string in the body of the message.  So thats clearly not the answer.
 
Contributor
peevedoffdeveloper
Posts: 35
Registered: ‎03-04-2013
My Device: 9850

Re: Share text message and email with subject.

I can do that if I want an actionitem for email only, but I was hoping for a way to do it like in the app world. One Share action for text message, bbm, group bbm, email, etc.

 

It will use text message body for text messages, bbm, etc but if the user picked email the subject appears as well.

 

 

Developer
mdodd
Posts: 188
Registered: ‎07-19-2012
My Device: Z10 LE

Re: Share text message and email with subject.

[ Edited ]

Sorry, not sure I made it clear in the last email. My method doesn't use that JSON map. All the data is encoded as a URL. So in your case it would be:

 

mailto:email@domain.com?subject=Some%20punctuation.%20Symbol&body=Hi!%20Here%20is%20some%20more%20stuff

 

EDIT: Thought I had what you needed, but lost it again, sorry!



Did this post help you? If so, please make sure to "like" it!
Contributor
peevedoffdeveloper
Posts: 35
Registered: ‎03-04-2013
My Device: 9850

Re: Share text message and email with subject.

Thanks I understant what you are doing with the uri mailto string. I do that specifically when I want an actionitem for contact us action to force sending an email in that case.

 

I posted my 2nd comment in response to my first just but was posted seconds after your response.

 

I was hoping for a one share action to rule them all sort of thing. Where I can add in the extra subject for email that can use it and other types just ignore it like for text messages exactly how app world app is doing it. I am not sure if this is some private method that rim is using that developers don't have access too. 

 

 

Developer
noahhuang
Posts: 100
Registered: ‎10-01-2012
My Device: BB10 Dev Alpha

Re: Share text message and email with subject.

void App::invokeShareMail() {
// Create a new invocation request
InvokeRequest request;
// Setup the request properties according to the current configuration
request.setAction("bb.action.COMPOSE");
request.setMimeType("message/rfc822");
QString mail = QString("mailto:%1?subject=%2&body=%3").arg("").arg("Your subject").arg(SHARE_MSG);
request.setUri(QUrl(mail));
 
request.setTarget("sys.pim.uib.email.hybridcomposer");
 
// Start the invocation
const InvokeReply *reply = m_invokeManager->invoke(request);
if (reply) {
// Ensure that processInvokeReply() is called when the invocation has finished
QObject::connect(reply, SIGNAL(finished()), this, SLOT(processInvokeReply()));
} else {
return;
}
}

 

Just for sharing what I did in my app.

Contributor
peevedoffdeveloper
Posts: 35
Registered: ‎03-04-2013
My Device: 9850

Re: Share text message and email with subject.

Thanks for the help. But I think that will just allow me to send an email.

 

What I am looking for is the bahaviour that is shown by the bb app world app when clicking share. 

 

Is it possible to create one invocation request that will populate the text date for bbm, bbm group, text message as normal and provide email body and subject when selecting email.

 

Or is this done by a number of individual invocation requests for each type. text message, bbm, bbm message, email.

 

 

BlackBerry Development Advisor
MSohm
Posts: 14,757
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: Share text message and email with subject.

Assuming you want to bring up the Cascades selection page for share targets, you can use code similar to what is below.  The example is for an image, but the same concept works for text as well.

 

void BBMInvocation::shareImageBound()
{
	QString path = QDir::current().absoluteFilePath("shared/photos/avatar.jpg");
	m_pInvocation = Invocation::create(
			InvokeQuery::create().parent(this).mimeType("image/png").uri(
					QUrl::fromLocalFile(path)));
}

void BBMInvocation::onArmed()
{
	m_pInvocation->trigger("bb.action.SHARE");
}

 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Contributor
peevedoffdeveloper
Posts: 35
Registered: ‎03-04-2013
My Device: 9850

Re: Share text message and email with subject.

I guess I am not explaining this clearly enough.

 

I currently am doing this

 

           InvokeActionItem {
                id: myshareaction
                title: "Share"
                ActionBar.placement: ActionBarPlacement.OnBar
                query {
                    mimeType: "text/plain"
                    invokeActionId: "bb.action.SHARE"
 
                }
                onTriggered: {
                    data = "Hey look at this app "+_myappname
                }
 
            }
 
 
The action works well. It brings up a sheet and I can share the text. However email comes up as a matching query and only the body of the email is popualated, not the subject line for that.
 
If I open the bb app world app and click on a app and click the share action on the bottom of the page I get the same popup sheet the I get in my example but when I click email there it does populate the subject. So what is the correct way to populate the data in order to get the subject to show up in emails. I am assuming that in the app world app the share action is being done by a similar single invoke action. That may not be the case.