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
Posts: 29
Registered: ‎01-06-2013
My Device: BB10 simulator
My Carrier: Verizon

Re: Dynamic InvokeQuery

Hi georg22,

 

I have been primarily working in QML and am attempting to build a shim for dynamic sharing as you suggested.

 

I have verified that I can call my class from QML and return a value, so I am good there, but when I add your code I get an error " 'InvokeRequest' was not declared in this scope"

 

What are the dependencies on this code snippet other than?

#include <bb/system/InvokeRequest>

 

Here is MyClass.cpp file:

#include "MyClass.hpp"
#include <bb/system/InvokeRequest>

MyClass::QMLclipboard()
{

}

MyClass::~QMLclipboard()
{

}

void MyClass::invokeShare(const QString &uri) {
	InvokeRequest request;
	request.setAction("bb.action.SHARE");
	request.setMimeType("image/png");
	request.setUri("icon.png");
	const InvokeReply *reply = m_invokeManager->invoke(request);
}

 

Any help would be much appreciated!!

 

Thanks,

Kurt 

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Dynamic InvokeQuery

add this:

using namespace bb::system;

 

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 50
Registered: ‎11-15-2012
My Device: Q10
My Carrier: WIND

Re: Dynamic InvokeQuery

@sf18443 that's interesting.  Maybe it somehow only works on an InvokeActionItem?  I assume you update that query using some JavaScript somewhere?  Unfortunately, I want the invocation to happen on tap on a list item, so don't really want any sort of ActionItem.

Contributor
Posts: 29
Registered: ‎01-06-2013
My Device: BB10 simulator
My Carrier: Verizon

Re: Dynamic InvokeQuery

@ekke thanks, that worked for a couple calls. I was also missing a few other includes.

#include <bb/system/InvokeReply>
#include <bb/system/InvokeManager>

The code runs now and I can see a debug statement in the console, but I don't see a card come up for the user to select the application they want to share with... is that expected?

Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Dynamic InvokeQuery

think the URI has to start with file://

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 19
Registered: ‎11-11-2012
My Device: Z10, DevAlphaC, Torch 9810, PlayBook
My Carrier: Movistar

Re: Dynamic InvokeQuery

Hi singpolyma

 

I got exactly what you want like this...

 

It's working right now on my Dev Alpha with Gold SDK

 

ListView {
  objectName: "bookmarks"

  listItemComponents: [
    ListItemComponent {
      type: "item"

      StandardListItem {
        imageSource: ListItemData.favicon
        title: ListItemData.title
        description: ListItemData.url
      }
    }
  ]

  attachedObjects: [
    Invocation {
      id: invokeBrowser
      query: InvokeQuery {
        id: invokeQuery
        invokeTargetId: "sys.browser"
        onQueryChanged: invokeQuery.updateQuery();
      }
    }
  ]

  onTriggered: {
    var selectedItem = dataModel.data(indexPath)
    invokeQuery.uri = selectedItem.url
    invokeBrowser.trigger("bb.action.OPEN")
  }
}

Contributor
Posts: 16
Registered: ‎04-05-2009
My Device: Bold 9930, PlayBook, and Dev Alpha
My Carrier: Verizon Wireless

Re: Dynamic InvokeQuery

I am using the example I posted to open whatever the url is currently in a webview in the browser. So, I thought maybe it would help indirectly (since it updates the query)
Developer
Posts: 19
Registered: ‎11-11-2012
My Device: Z10, DevAlphaC, Torch 9810, PlayBook
My Carrier: Movistar

Re: Dynamic InvokeQuery

[ Edited ]

WAIT!!!

 

I found the problem! Sorry! ...you have to wait for the invocation to get armed!!!

 

This definetly works!

 

ListView {
  objectName: "bookmarks"

  listItemComponents: [
    ListItemComponent {
      type: "item"

      StandardListItem {
        imageSource: ListItemData.favicon
        title: ListItemData.title
        description: ListItemData.url
      }
    }
  ]

  attachedObjects: [
    Invocation {
      id: invokeBrowser
      query: InvokeQuery {
        id: invokeQuery
        invokeTargetId: "sys.browser"
      }
      onArmed: {
        trigger("bb.action.OPEN")
      }
    }
  ]

  onTriggered: {
    var selectedItem = dataModel.data(indexPath)
    invokeQuery.uri = selectedItem.url
    invokeQuery.updateQuery()
  }
}

Contributor
Posts: 29
Registered: ‎01-06-2013
My Device: BB10 simulator
My Carrier: Verizon

Re: Dynamic InvokeQuery

Thanks!

 

That definitely works, but something weird is going on as well. If you add a valid uri upfront, then the Invocation seems to fire immediately when the app launches. For example, I added "yahoo.com" as the default uri:

 

 attachedObjects: [
                Invocation {
                  id: invokeBrowser
                  query: InvokeQuery {
                    id: invokeQuery
                    invokeTargetId: "sys.browser"
                    uri: "http://www.yahoo.com"
                  }
                  onArmed: {
                    trigger("bb.action.OPEN")
                  }
                }
              ]

 

If I do that, then the browser immediately pops up, tries to open yahoo.com, and then crashes :/

 

If I comment it out, nothting happens until I click my list item... I wonder if it is repeatedly firing and erroring out silently until it has a valid set of parameters.

 

 

Contributor
Posts: 29
Registered: ‎01-06-2013
My Device: BB10 simulator
My Carrier: Verizon

Re: Dynamic InvokeQuery

Yep, this shows up in the console when the app launches:

InvocationWrapper:Smiley SurprisednQueryFinished: menu service population failed
query mimeType=""
query uri=QUrl("")
query data= ""
query metadata= QMap()
query action= ""
query target= ""
query perimeter= 0
invokerIncluded= false
MenuManager.error()= 1
InvocationPrivate:Smiley SurprisednQueryResolved: query failed, no armed signal sent.

Good news is, it just shows up once, so that is probably ok (it's not polling the API)