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: 206
Registered: ‎05-15-2012
My Device: None
My Carrier: Telus
Accepted Solution

Unbounded Invoke to Twitter/Facebook

[ Edited ]

I'm attempting to do an unbounded invoke with plain text that will target all applications that subscribe to the mimetype. Here is my code:

 

	InvokeManager *manager = new InvokeManager();
	InvokeRequest *request = new InvokeRequest();
	//request->setTarget("Twitter");
	request->setData(url.toUtf8());
	request->setMimeType("text/plain");
	request->setAction("bb.action.SHARE");
	manager->invoke(*request);

 This opens up a card to select a bbm group to share with.

 

If I uncomment the line of code that specifically targets twitter it will properly invoke twitter.

 

Why is it that all the possible receivers of text/plain are not listed as options to share with when I do my unbounded invoke?

----------------------
Check out my app, Alien Flow for reddit

And of course, like my post if you found it helpful or informative!
Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: Unbounded Invoke to Twitter/Facebook

[ Edited ]

When i attempted this with the invokemanager method i ended up with the same BBM groups page that you're getting i'm now using a c++/qml hybrid method

 

void myApp::share(QString text)
{
     printf("Share invoked");

     m_pInvocation = Invocation::create(
          InvokeQuery::create()
	       .parent(this)
	       .mimeType("text/plain")
	       .data(text.toUtf8()));
	  QObject::connect(m_pInvocation, SIGNAL(armed()),
	    this, SLOT(onArmed()));
	  QObject::connect(m_pInvocation, SIGNAL(finished()),
	    m_pInvocation, SLOT(deleteLater()));
}

 but i think if you change InvokeRequest to InvokeQuery, your method might yield desired results

Developer
Posts: 206
Registered: ‎05-15-2012
My Device: None
My Carrier: Telus

Re: Unbounded Invoke to Twitter/Facebook

[ Edited ]

I may have prematurely marked this resolved. I just get errors...

 

InvocationWrapper::smileysurprised:nQueryFinished: no matching result from Menu Service for query

 

InvocationPrivate::smileysurprised:nQueryResolved: no result matching query, no armed signal sent.

 

qDebug() << "Share: " << url;

	invocation = Invocation::create(
		InvokeQuery::create()
	  	  .parent(this)
	  	  .mimeType("text/plain")
	  	  .invokeActionId("bb.action.OPEN")
	  	  .data(url.toUtf8()));

	QObject::connect(invocation, SIGNAL(armed()),
		    this, SLOT(onArmed()));

	QObject::connect(invocation, SIGNAL(finished()),
			invocation, SLOT(deleteLater()));

 

----------------------
Check out my app, Alien Flow for reddit

And of course, like my post if you found it helpful or informative!
Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: Unbounded Invoke to Twitter/Facebook

[ Edited ]

Did you add the includes
#include <bb/cascades/Invocation>
#include <bb/cascades/InvokeQuery>

 

Also the invokeactionid should be bb.action.SHARE if you're trying to pull a list of targets

 

 

 

Developer
Posts: 206
Registered: ‎05-15-2012
My Device: None
My Carrier: Telus

Re: Unbounded Invoke to Twitter/Facebook

I included InvokeQuery and Invocation. Invoke does not appear to be a valid header?

----------------------
Check out my app, Alien Flow for reddit

And of course, like my post if you found it helpful or informative!
Developer
Posts: 206
Registered: ‎05-15-2012
My Device: None
My Carrier: Telus

Re: Unbounded Invoke to Twitter/Facebook

void Class::shareSelected()
{
	qDebug() << "Share: " << url;

	invocation = Invocation::create(
		InvokeQuery::create()
	  	  .parent(this)
	  	  .mimeType("text/plain")
	  	  .data(url.toUtf8()));

	QObject::connect(invocation, SIGNAL(armed()),
		    this, SLOT(onArmed()));

	QObject::connect(invocation, SIGNAL(finished()),
			invocation, SLOT(deleteLater()));
}

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

 This code works as expected.

----------------------
Check out my app, Alien Flow for reddit

And of course, like my post if you found it helpful or informative!
Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: Unbounded Invoke to Twitter/Facebook

[ Edited ]

was just about to say i forgot about

 

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

 but looks like you found it :smileyhappy: