Can't get the local cordova.js on a hosted https Blackberry App

88 Views Asked by At

I am using Blackberry WebWorks to try to make a WebApp that points to my site. My site is https. In the config.xml, I have <content src="https://example.com"/>

I also want to use some native functions of BB10, like sharing and toasting, so I also have the line <script src="local:///cordova.js" type="text/javascript" ></script> on https://example.com.

But once I run the app, the web inspector console says:

[blocked] The page at https://example.com ran insecure content from local:///cordova.js.

And variable blackberry is undefined so I cannot call the Blackberry functions.

How can I solve it? Your help is very much appreciated. Thank you very much!

2

There are 2 best solutions below

1
hanamj On

I don't know how to solve this exactly...but this is what I'd try. Add this to config.xml:

<preference name="WebSecurity" value="disable"/>

I'd also try this, if the above doesn't work:

<access origin="local://" />

or

<access origin="local://cordova.js" />

Good luck!

0
gmm900913 On

This is the first post of mine (also new to BB dev) so suggest if anything is not correct and accept my sincere appologies. I am giving you step by step I hope you don't get offended as others who are new to BB dev see this as helpful for them.

Step 0: Start the "BlackBerry 10 Simulator".
Step 1: Start the "BlackBerry WebWorks 2.2.0.15"
Step 2: "BlackBerry WebWorks 2.2.0.15" once started opens the browser with localhost:3123/
Step 3: Create a sample project by giving
Create Project
PROJECT ID
PROJECT NAME
PROJECT PATH
Step 4: This would create a project with index.html file
Step 5: Click on plugins tab on the browser with localhost:3123 and add "com.blackberry.invoke"
Step 6: Replace the body section of code of index.html with the code mentioned below:-

<body>
    <div class="app">
        <a onclick="openWebLink()"> Click me to test Opening https </a>
        <div id="deviceready" class="blink">
            <p class="event listening"> </p>
            <p class="event received"> </p>
        </div>
    </div>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript">
        app.initialize();

        function onInvokeSuccess() {
            console.log("Invocation successful!");
        }

        function onInvokeError(error) {
            console.log("Invocation error!");
        }

        function openWebLink() {
            blackberry.invoke.invoke({
                uri: "https://www.hsbc.co.uk/1/2/"
            }, onInvokeSuccess, onInvokeError);
        }
    </script>
</body>

Step 7: Click on build tab on the browser
Choose
Build Mode : DEBUG MODE
and
Target Type : SIMULATOR
Step 8: Click on build and install. Once ready opens the app on the simulator and prompts with OK button click on it.
Step 9: Again click on "Click me to test Opening https" it opens a browser with secure url
Step 10: If this works for you might give you a hint on how you want to proceed.