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: 26
Registered: ‎09-20-2013
My Device: Z10
My Carrier: Orange

url schemes and webview

I use webview to show some pages from my client in my app. I need to catch the navigation requests and launch device applications, such as blackberry world, video player, phone, sms, email and etc. But, I can't find the url schemes that the webview support. Is there any documents for bb10 about the url schemes?

BlackBerry Development Advisor
Posts: 15,753
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: url schemes and webview

If you are looking to catch navigation events and handle them outside your application, you could use the code below.  It allows for setting HTML content in a WebView programmatically, but redirects any other requests to the browser.

 

//Implement this within your WebView
onNavigationRequested: {
    //Open links in the browser. 
    //Only allow other, which is us setting the HTML content.
    if (WebNavigationType.Other == request.navigationType) {
        request.action = WebNavigationRequestAction.Accept;
    } else {
        request.action = WebNavigationRequestAction.Ignore;
        linkInvocation.query.uri = request.url;
    }
}

//snip... then add this to your page

attachedObjects: [
        Invocation {
            id: linkInvocation
            property bool auto_trigger: false
            query {
                uri: "http://developer.blackberry.com"

                onUriChanged: {
                    linkInvocation.query.updateQuery();
                }
            }
            onArmed: {
                // don't auto-trigger on initial setup
                if (auto_trigger) {
                    trigger("bb.action.OPEN");
                }
                auto_trigger = true; // allow re-arming to auto-trigger
            }
        }
    ]

 

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker