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: 386
Registered: ‎07-20-2012
My Device: Blackberry Z10 (White), BlackBerry Dev Alpha C
My Carrier: O2 UK

URL Invocation Bug

Hello, 

 

I have recently added URL invocation into one of my BlackBerry 10 apps but I've noticed an issue - I'm not sure if it's due to my code or a bug in the OS. 

 

When the user clicks a URL that is one of my URIs, they can hold it, click "open in", click "set default" and open it in my app (loads the webView within my app perfectly.) but if the user (after settings my app as default) tries to click another link, it will just open the app rather than the loading the webView with the specific URL that the user has clicked on. 

 

Here's the code I am using for my URL Invocation:

 

ApplicationUI.cpp:

 

void ApplicationUI::onInvoked(const bb::system::InvokeRequest& invokeRequest)
{

    if (invokeRequest.action() == "bb.action.SEARCH.EXTENDED") {
        // Begin searching in app
        _root->setProperty("searchString", QString(invokeRequest.data()));
        emit sendsearchtoqml(QString(invokeRequest.data()));
    }
    if (invokeRequest.action() == "bb.action.OPEN") {
        // call emit here
        QUrl url = invokeRequest.uri();
        QString tempURL = url.toString();
        emit sendtoqml(tempURL);
    }
}

 ApplicationUI.hpp:

 

signals:
    void sendtoqml(QString strURL);
    void sendsearchtoqml(QString strSearch);

...

public slots:
    void onInvoked(const bb::system::InvokeRequest& invokeRequest);

 Main.qml:

 

function invokedURLHandler(strURL) {
            amazonUK.url = strURL;
        }
        function dosearch(strSearch) {
            _app.searchThis(strSearch)
            amazonUK.url = radioGroup.selectedValue + "/s/ref=is_box_?k=" + searchField.text.replace(" ", "+")
        }
        onCreationCompleted: {
            _app.sendtoqml.connect(invokedURLHandler);
            _app.sendsearchtoqml.connect(dosearch);
        }

 BarDescriptor.xml:

 

<!-- URL Invocation -->
	<invoke-target id="tcs.shoppingforamazon.urlinvoke">
    <invoke-target-type>application</invoke-target-type>
    <invoke-target-name>Shopping For Amazon</invoke-target-name>
    <icon><image>icon.png</image></icon>
    <filter>
        <action>bb.action.VIEW</action>
        <action>bb.action.OPEN</action>
        <mime-type>*</mime-type>
        <property var="uris" value="http://www.amazon.com.au/, http://www.amazon.com.br, http://www.amazon.ca/, http://www.amazon.cn, http://www.amazon.fr, http://www.amazon.de/, http://www.amazon.in/, http://www.amazon.it/, http://www.amazon.co.jp/, http://www.amazon.com.mx/, http://www.amazon.es/, http://www.amazon.co.uk/, http://www.amazon.com/ "> </property>
    </filter>
</invoke-target>

 Any help with this would be greatly appricated. 

 

Thanks in advance Smiley Happy