Search code examples
javascriptcordovablackberry-10

window.open() makes my app crash on blackberry10


I am struggeling with my blackberry10 application. Basically I want to open the BlackBerry World page of my application by pressing on a button in a confirmation dialog.

function onButtonPressed() {
    var url = "appworld.blackberry.com/webstore/content/XXXXXXXX"
    window.open( url, "_blank" );
}

But after pressing my button the app craches immediately without any error in the debug console. I also tried to use "_system" instead of "_blank" without success. However on android my approach works flawlessly.

Are there any further hints or tips to investigate/solve this problem?


Solution

  • I solved my issue by using another cordova plugin.

    cordova plugin add cordova-plugin-bb-invoke
    

    Now I am able to open the BlackBerry World application directly:

    function openAppStore() {
    
        var platform = $cordovaDevice.getPlatform().toLowerCase();
        var url;
    
        switch( platform ) {
            case "blackberry10":
                url = "appworld://content/xxxxxxxx";
                break;
            default:
                url = "anotherPlatformUrl"
        }
    
        if( platform === "blackberry10" ) {
            blackberry.invoke.invoke( {
                uri    : url
            }, onInvokeSuccess, onInvokeError );
        } else {
            window.open( url, "_system" );
        }
    
        function onInvokeSuccess() {
            console.log( "Invoke Success!" );
        }
    
        function onInvokeError( error ) {
            console.log( "!!! Invoke Error: ", error );
        }
    }