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
New Contributor
Posts: 7
Registered: ‎07-24-2012
My Device: Z10
My Carrier: Vodafone

Invoking own custom card from within own application

Hi,

 

I want to create a card previewer that I can invoke from within my application.

 

I want to be able to pass data from my application to the viewer and the viewer displays this information then the user can peek and close the card which will return to my application underneath.

 

I imagine that this is what happens with the native twitter client for example when you view a tweet? Please correct me if I'm wrong.

 

Is it achievable using the html5 framework?

 

If it is achievable from what I have read I can't see how you would get it to work as you need to define a listener: 

blackberry.event.addEventListener("invoked", function (onInvokedInfo) {}

However I'm assuming that this would try and invoke an index.htm file which already exists as the start point to my app.

 

How would I go about ensuring that it is a different htm file that is used when my app card is invoked?

 

Thanks.

 

 

Retired
Posts: 245
Registered: ‎09-21-2012
My Device: Q10
My Carrier: Virgin

Re: Invoking own custom card from within own application

[ Edited ]

Hey Matt,

 

Awesome deductions on how you might do this. There are actually a couple different ways you can accomplish this with varying performance etc. Here is where I will steer you towards:

 

1. Create a bar file in WebWorks that is able to be invoked as an "APPLICATION" and as a "VIEWER" or card. You will need to use the invoke-target property in your config: http://developer.blackberry.com/html5/documentation/rim_invoke-target.html

 

2. Hook a listener to the webworks ready event that checks what type of startup this was for you. Check out the demo Chad put together here: https://github.com/blackberry/BB10-WebWorks-Samples/blob/master/invoke/invokable/index.html

 

Especially this line: invocationInfo.type. Then you can set what HTML file of the page.

 

3. Invoke the application using blackberry.invoke.

 

So the answer to your question is yes. There is a more performant solution but requires a custom extension. Let me know how it goes.

@erikjohnzon
erjohnson@blackberry.com
New Contributor
Posts: 7
Registered: ‎07-24-2012
My Device: Z10
My Carrier: Vodafone

Re: Invoking own custom card from within own application

Thanks.

I have managed to get it to invoke by:

having my application config as:

 

<rim:invoke-target id="xxxx">
<type>CARD.PREVIEWER</type>
<filter>
<action>bb.action.VIEW</action>
<mime-type>text/plain</mime-type>
</filter>
</rim:invoke-target>

 

and my invoke as:

blackberry.invoke.invoke({
target: "com.bbuk.viewdeal",
type: "text/plain",
action: "bb.action.VIEW"
}, onInvokeSuccess, onInvokeError);

 

I have got it to print out all of the stated code such as invocationInfo.type, but it is still invoking a card containing index.htm of my application ontop of my running applicaiton.

 

I require invoked application to be a defined html page which I can manipulate with data passed in under the data attribute of the invoke message.

How can this be acheived?

 

I also need to have the peek swipe functionality to return to the tunning application underneath.

 

Thanks,

 

Matt

 

Highlighted
Retired
Posts: 245
Registered: ‎09-21-2012
My Device: Q10
My Carrier: Virgin

Re: Invoking own custom card from within own application

You will need to add a custom JS extenison to trap and overwrite the loaded URL of the webview on bootup. When you do this, you tell the webview to load your new "card.html" vs the index.html you specified in your config file.

 

Does that make sense? You need something like this inside the index.js of your JS extension:

 

1. Get invocation mode as normal or invoke:

 

var request = JSON.parse(window.qnx.webplatform.getApplication().invocation.getRequest());

2. Set the webview URL based on the requested startup invocation

qnx.webplatform.getController().addEventListener("webview.initialized", function (webview) {
    if(request.action === "Something" || request.something === "Something else") {
        webview.url = "card.html" // page sitting inside your bar file
    }
}

This is dipping outside WW a bit, so try and checkout some of the properties on the request object we made and see what it contains as options etc for yourself to use.

@erikjohnzon
erjohnson@blackberry.com