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
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: InvokeActionItem 10.2

The issue is only present with the QML InvokeActionItem with a target specified. You can either not specify the target and let the system handle it for you (this is generally recommended anyway) or if you really need to invoke a specific app, do so from C++ using something similar to Slashkyle's method. You can also just not do anything, as it will fail silently for the user (they won't see the action item). So if it's not a super important part of your app, it will just be gone for now and then magically start working again when we fix the issue.

 

The bug does seem to be present in the builds going out to users, unfortunately, so you will need to decide on how to handle it.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
Posts: 993
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: InvokeActionItem 10.2

Thanks for your feedback, but your statement is not entirely accurate. While I did encounter this problem in one location with InvokeActionItem, in several other locations in my app I was using a different mechanism but encountered the same problem:

 

void MyClass::InvokeBrowser( QUrl url ) {
    bb::cascades::Invocation* invocation = Invocation::create( InvokeQuery::create().parent( this ).mimeType( "text/html" ).uri( url ).invokeTargetId( "sys.browser" ).invokeActionId( "bb.action.OPEN" ) );
    success = QObject::connect( invocation, SIGNAL(armed()), this, SLOT(browserInvocationArmedHandler()) );
    ASSERT( success );
    success = QObject::connect( invocation, SIGNAL(finished()), invocation, SLOT(deleteLater()) );
    ASSERT( success );
}

void MyClass::browserInvocationArmedHandler() {
    static_cast<bb::cascades::Invocation*>( sender() )->trigger( "bb.action.OPEN" );
}

This is one of several methods for invoking the browser I have found in the documentation or in these forums, but it too fails to do the invocation, despite having worked with 10.0 and 10.1.

 

Luckily Slashkyle's method works perfectly for me so I am back in business, but your assertion this problem only affects InvokeActionItem is incorrect.


PBernhardt wrote:

The issue is only present with the QML InvokeActionItem with a target specified. You can either not specify the target and let the system handle it for you (this is generally recommended anyway) or if you really need to invoke a specific app, do so from C++ using something similar to Slashkyle's method. You can also just not do anything, as it will fail silently for the user (they won't see the action item). So if it's not a super important part of your app, it will just be gone for now and then magically start working again when we fix the issue.

 

The bug does seem to be present in the builds going out to users, unfortunately, so you will need to decide on how to handle it.






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: InvokeActionItem 10.2

I apologize, it IS actually the InvokeQuery that has the problem. It's just that people generally get to it using an InvokeActionitem.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
Posts: 993
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: InvokeActionItem 10.2

[ Edited ]

Thanks so much for this post, it does indeed still work on 10.2! Saw your post yesterday but didn't have time to test it till today. I would give you a dozen "likes" if I could.

 

I am aware of at least three other methods for invoking the browser, all of which were broken by 10.2 because, as was pointed out by 

 

1.) This is the first method I learned back when I started developing my multiFEED application. It can be called from anywhere in your app, not just from an ActionItem.

 

void MyClass::InvokeBrowser( QUrl url ) {
    bb::cascades::Invocation* invocation = Invocation::create( InvokeQuery::create().parent( this ).mimeType( "text/html" ).uri( url ).invokeTargetId( "sys.browser" ).invokeActionId( "bb.action.OPEN" ) );
    success = QObject::connect( invocation, SIGNAL(armed()), this, SLOT(browserInvocationArmedHandler()) );
    ASSERT( success );
    success = QObject::connect( invocation, SIGNAL(finished()), invocation, SLOT(deleteLater()) );
    ASSERT( success );
}

void MyClass::browserInvocationArmedHandler() {
    static_cast<bb::cascades::Invocation*>( sender() )->trigger( "bb.action.OPEN" );
}

 

2.) This method is similar to the first, but triggers the browser invocation directly from an ActionItem. On BB 10.2 the ActionItem button is still visible, but does nothing when tapped.

 

MyPage::MyPage() {
    browserAction = ActionItem::create().parent( this ).imageSource( QUrl( "asset:///images/Browser.png" ) ).title( tr( "Browser" ) );
    QObject::connect( browserAction, SIGNAL(triggered()), this, SLOT(browserActionTriggeredHandler()) );
    this->addAction( browserAction );
} 

void MyPage::browserActionTriggeredHandler() {
    bb::cascades::Invocation* invocation = Invocation::create( InvokeQuery::create().parent( this ).mimeType( "text/html" ).uri( "http://targeturl.html" ).invokeTargetId( "sys.browser" ).invokeActionId( "bb.action.OPEN" ) );
    QObject::connect( invocation, SIGNAL(armed()), this, SLOT(browserInvocationArmedHandler()) );
}

void MyPage::browserInvocationArmedHandler() {
    static_cast<bb::cascades::Invocation*>( sender() )->trigger( "bb.action.OPEN" );
}

 

3.) The way dispenses with the need to connect any signals and slots, but has the added disadvantage that if you specify the target ID, the InvokeActionItem button won't even be displayed on BB 10.2.

 

MyPage::MyPage() {
    InvokeQuery* fullBrowserQuery = InvokeQuery::create().parent( this ).invokeActionId( "bb.action.OPEN" ).mimeType( "text/html" ).invokeTargetId( "sys.browser" ).uri( "http::/targeturl.html" );
    browserAction = InvokeActionItem::create( fullBrowserQuery ).parent( this ).imageSource( QUrl( "asset:///images/Browser.png" ) ).title( tr( "Browser" ) );
    this->addAction( browserAction );
} 

 

As I stated, none of these three methods works under current BB 10.2 releases, so don't use them in your code. 's solution works perfectly, so I am in the process of converting all my invocations now.

 


slashkyle wrote:

are you guys doing this from qml?

 

I had issues about a year ago in 10.0 with it and switched to a c++ version that still works on the latest update

 

I just tested and this works as well

 *Assuming a context property is setup in this example it's cpp.

applicationUI.cpp

#include <bb/system/InvokeRequest>
#include <bb/system/InvokeManager>
#include <bb/system/InvokeTargetReply>

 

void ApplicationUI::invokeBrowser()
{
	InvokeManager manager;
	InvokeRequest request;

	// Setup what to show and in what target.
	request.setTarget("sys.browser");
	request.setAction("bb.action.OPEN");
	request.setUri("http://www.blackberry.com/");
	InvokeTargetReply *targetReply = manager.invoke(request);
	//setting the parent to "this" will make the manager live on after this function is destroyed
	manager.setParent(this);

	if (targetReply == NULL) {
		qDebug() << "InvokeTargetReply is NULL: targetReply = " << targetReply;
	} else {
		targetReply->setParent(this);
	}
}

 

 

applicationUI.hpp

public:
    ApplicationUI(bb::cascades::Application *app);
    virtual ~ApplicationUI() { }

    Q_INVOKABLE void invokeBrowser();

 .qml

 

Button {
  onClicked: {
     cpp.invokeBrowser();
  }
}



Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 313
Registered: ‎03-13-2013
My Device: Z10
My Carrier: Tim

Re: InvokeActionItem 10.2

It's already accepted as a solution :smileyhappy:

If this post is helpful, please click the "like" button! :smileyhappy:
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: InvokeActionItem 10.2

That was me, sorry :smileyhappy:

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
Posts: 993
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: InvokeActionItem 10.2

Oops, sorry. It is hard to tell when you are at the end of a long post if the status of the thread has changed in the meantime. LOL

 


davide13 wrote:

It's already accepted as a solution :smileyhappy:






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 29
Registered: ‎04-02-2013
My Device: BlackBerry Z10
My Carrier: Telus

Re: InvokeActionItem 10.2

I tried to implement slashkyle's solution but it keeps opening a NFC share card when I set the target to "Twitter". I am trying to open the Facebook and Twitter compose cards.

 

void ApplicationUI::shareContent(QString target){
	InvokeManager manager;
	InvokeRequest request;

	// Setup what to show and in what target.
	request.setTarget(target);
	request.setAction("bb.action.SHARE");
	InvokeTargetReply *targetReply = manager.invoke(request);
	//setting the parent to "this" will make the manager live on after this function is destroyed
	manager.setParent(this);

	if (targetReply == NULL) {
		qDebug() << "InvokeTargetReply is NULL: targetReply = " << targetReply;
	} else {
		targetReply->setParent(this);
	}

}

 On another note, is there any way to detect if someone posts or tweets versus cancels the action from the facebook and twitter cards? 

Developer
Posts: 824
Registered: ‎10-16-2012
My Device: Red Z10
My Carrier: Telus

Re: InvokeActionItem 10.2

it should work if you're using the proper uri's and target id's found here

https://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/invoking_c...

 

I belive to detect if they sent the message or cancelled you would need to build onto the targetReply and detect what it was and then process based on that result, haven't done this myself so i'm not 100% certain.

Developer
Posts: 29
Registered: ‎04-02-2013
My Device: BlackBerry Z10
My Carrier: Telus

Re: InvokeActionItem 10.2

Thanks for the quick reply!

I forgot to set the MimeType, it works now. I'm going to dig a little deeper into how build onto targetReply and I'll post it here.