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

Web and WebWorks Development

Reply
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

BB10 - blackberry.invoke.invoke - can't open a picture with example code

[ Edited ]

Hi,

 

I'm trying the "blackberry.invoke.invoke" API call on a BB10 Dev Alpha device to open a picture made by the camera from the camera's shared folder and tried the example provided here, but can't get it working:

 

function viewPicture() {
    // view picture
    blackberry.invoke.invoke({
        uri: entry.fullPath,
        action: bb.action.VIEW
    }, onInvokeSuccess, onInvokeError);
}

"entry" in the example above is my FileEntry object, so I'm passing the entry.fullPath. Right now it is throwing an

TypeError: 'undefined' is not an object (evaluating 'blackberry.action.VIEW') error. Hope somebody can help on this.

 

Regards.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: BB10 - blackberry.invoke.invoke - can't open a picture with example code

That's an unusual error.  I haven't seen that one before.  Glad you posted a code snippet though, I think I see a syntax error.

 

Can you try wrapping the bb.action.VIEW statement in quotes?  Like this:

 

function viewPicture() {
    // view picture
    blackberry.invoke.invoke({
        uri: entry.fullPath,
        action: "bb.action.VIEW"
    }, onInvokeSuccess, onInvokeError);
}

 

Its supposed to be a string, not an object.  I suspect the engine is trying to evaluate it and failing to find the right reference.

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: BB10 - blackberry.invoke.invoke - can't open a picture with example code

Hi,

 

thx for your response Adam. If you have a closer look to the "invoke" documentation you can see that it is an issue of the documentation since my source is copy+paste directly from there.

 

I also wonder how it could work to call "bb.action.VIEW" action since there are no apps installed on the BB10 Dev Alpha!? For now I'm trying to get into as much API's as possible to understand them and to see how to use them, so I think I need to write my own app for those things?!

 

Regards.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: BB10 - blackberry.invoke.invoke - can't open a picture with example code

Good find.  I've filed an bug for this issue here:

https://github.com/blackberry/WebWorks-API-Docs/issues/339

 

 

Right now you cannot launch apps that do not exist.  You will get an INVOKE_NO_TARGET_ID error message if you do. I've submitted a pull request to the invoke code sample in Github to help explain this behavior:

 

https://github.com/astanley/BB10-WebWorks-Samples/commit/e76c8d5f7db2038e5eb97444e71a8ce92043ede9

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: BB10 - blackberry.invoke.invoke - can't open a picture with example code

Hi Adam,

 

thx for your response and that you filed a bug for the issue. Btw: I got the "INVOKE_NO_TARGET_ID" error message and I fixed it for now by trying out the invoke example for BB10 to know how it works.

 

Regards.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: BB10 - blackberry.invoke.invoke - can't open a picture with example code

Hi adam/all,

 

I tried to go on working with the blackberry.invoke.invoke on BB10 with the following example:

 

blackberry.invoke.invoke({uri: "https://developer.blackberry.com/html5/apis/blackberry.identity.html"}, function(successEvt) {console.log(successEvt);}, function(errorEvt) {console.log(errorEvt);});

In the docs there is somehow the same sample source provided in:

 

function openWebLink() {
    // open web link - allows the system to choose an appropriate target that handles http://
blackberry.invoke.invoke({ uri: "http://www.blackberry.com" }, onInvokeSuccess, onInvokeError); }

The only thing I used for the example is https, isn't it? In all my cases it throws an "INVOKE_NO_TARGET_ERROR" error to console and isn't open up the browser. Seems the browser isn't invokable in this case?

 


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Retired
Posts: 1,382
Registered: ‎07-02-2009
My Device: BlackBerry Bold 9900
My Carrier: Bell

Re: BB10 - blackberry.invoke.invoke - can't open a picture with example code

INVOKE_NO_TARGET_ERROR should be expected on 10.0.386 of the BB10 OS.  This means that the invokation framework is not able to find the target.  Mostly this is because 10.0.386 has very few (no?) targets.  This will be improved in future versions of the OS.  For example, when invoking the browser using the sample code you have provided, the invokation framework is looking for the sys.browser application (by default).  However this app is not included in that build - the AIR browser is however (which unfortunately is not registered with the invocation framework).

 

Check out the sample app we have published here:

https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/invoke

I recently added a "troublshooting" section and included that error message.

 

You will see in this sample that there is an "invokable" sample where the app registers itself as a target.

 

Follow me on Twitter: @n_adam_stanley
-------------------------------------------------------------------------------------------------------------------------
Your app doesn't work? Use BlackBerry remote web inspector to find out why.
Developer
Developer
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: BB10 - blackberry.invoke.invoke - can't open a picture with example code

THX again for your response Adam.

 

Yesterday was looking for NFC on BB10 again and installed the Cascades NFC example. By this, and together with the Invoke/Invokable example you mentioned I got it running in a small testimonial app to be invoke if dev alpha reads a NFC tag and in that way the system invokes the app and redirects the content of the NFC tag to my testimonial, so I think I got it working for that case.

 

The difference between the installed air.browser and the sys.browser is something that I wanted to point out in this thread, since the documentation also points to a somehow broken example source code that couldn't work with the latest BB10 and that is confusing and frustrating when you expect a result, that won't be until the next beta release, because of such things.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
New Contributor
Posts: 9
Registered: ‎06-08-2014
My Device: Blackberry Q10
My Carrier: AT&T, Oreedoo, Etisalat, Vodafone

Re: BB10 - blackberry.invoke.invoke - cant invoke files on device, apps(browser, facebook etc)

[ Edited ]

Hey im building my first app for my campus organization and need help im experiencing errors:-

  • NETWORK_ERR: XMLHttpRequest Exception 101: A network error occurred in synchronous requests.
  • TypeError: 'null' is not an object (evaluating 'document.getElementById('Contacts').style')
  • TypeError: 'undefined' is not an object (evaluating 'blackberry.invoke.invoke')

the app im building linkes to all the different organization pages and  and links to info as well as files. here is my js and xml file.-------------------------------------------------------------------------------------------------------------------------------------------

<widget id="group"
xmlns="http://www.w3.org/ns/widgets"
xmlns:cdv="http://cordova.apache.org/ns/1.0"
xmlns:rim="http://www.blackberry.com/ns/widgets" version="0.0.1">
<!--preference name="AutoHideSplashScreen" value="true" /><preference name="ChildBrowser" value="enable" /><preference name="DiskCache" value="disable" /><preference name="HideKeyboardFormAccessoryBar" value="disable" /><preference name="Orientation" value="default" /><preference name="PopupBlocker" value="disable" /><preference name="WebSecurity" value="enable" /-->
<access origin="*"/>
<preference name="BackgroundColor" value="0xff000000"/>
<description>App</description>
<content src="index.htm"/>
<icon src="img/pic2.png"/>
<rim:splash src="img/pic1.png"/>
<name>App</name>
<rimSmiley Tongueermissions>
<rimSmiley Tongueermit>access_shared</rimSmiley Tongueermit>
<rimSmiley Tongueermit>read_device_identifying_information</rimSmiley Tongueermit>
</rimSmiley Tongueermissions>
<author>Name</author>
</widget>

-----------------------------------------------------------------------------------------------------------------------------------------------------------

function facebookApp() {
var request = {
"target": "Facebook",
"action": "bb.action.SHARE",
"type": "text/plain",
"data": "Post:Whats on your mind?"
};
invokeApp(request);
}

function facebookPage0() {
var request = {
target: "com.rim.bb.app.facebook",
action: "bb.action.OPEN",
metadata&colon; JSON.stringify({
object_type: 'page',
object_id: '351415237658'
})
};
invokeApp(request);
}

function Instagram() {
var request = {
target: "sys.browser",
uri: "http://instagram.com/"
};
invokeApp(request);
}

function adobeReaderPdf1() {
var request = {
target: "com.rim.bb.app.adobeReader.viewer",
action: "bb.action.VIEW",
type: "application/pdf",
url: "file:///Device/documents/KHR/Organization-Laws.pdf",
extensions:".pdf"
};
invokeApp(request);
}

function invokeApp(request) {
blackberry.invoke.invoke(
request,
function() {
console.log('success');
},
function(e) {
console.log('error');
console.log(e);
}
);
}

function phone() {
var request = {
uri: "tel:3217532690"
};
invokeApp(request);
}

function invokeApp(request) {
blackberry.invoke.invoke(
request,
function() {
console.log('success');
},
function(e) {
console.log('error');
console.log(e);
}
);
}

-----------------------------------------------------------------------------------------------------------------------------------------------------------

ive also added com.blackberry plugins (.app, .bbui, .invoke, .invoke.card, ui.contextmenu) and Access List Origin"*".  i really appreciate the help, thanks. Yours sincerely New_timer