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 Developer
Posts: 43
Registered: ‎03-10-2014
My Device: Z30
My Carrier: Bell

How to get rid of "Open Application" popup window

Hi there,

 

I'm new to BB App development. I just installed Web Works and created a simple app. My app lists 3 links and when a link is clicked a PDF file is opened in Acrobat Reader.  Before Acrobat Reader is launched , I get a popup window titled Open Application and it says - Do you want to open the link "file:///accounts/1000/invoke/sys.brow with Adobe Reader. If you did not initiate this request, you should click Cancel."

 

If I click OK, the PDF opens up.  My questions are:

(1) Is there a way to get rid of this popup message?

(2) In all other apps that I used, I never saw such a message. Is there something I'm doing is wrong?

(3) I don't understand this path. It's like it is cut off.

 

Thanks for you help in advance,

 

Joe

 

BlackBerry Development Advisor
Posts: 43
Registered: ‎01-11-2013
My Device: BlackBerry Z10
My Carrier: Rogers

Re: How to get rid of "Open Application" popup window

You should probably be invoking the Adode Reader App:

https://developer.blackberry.com/html5/documentation/v2_0/adobereader.html

 

For details on how to use the invocation framework have a look at:

https://developer.blackberry.com/html5/documentation/v2_0/sending_invocation.html#ufa1344348657118

 

Also a sample app using Invocation Smiley Happy https://github.com/blackberry/BB10-WebWorks-Samples/tree/WebWorks-2.0/Invocation

 

Hope that helps.

--
Senior Systems Software Developer - Enterprise R&D

@roryboy

1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the like/thumbs up button below the post(s)
New Developer
Posts: 43
Registered: ‎03-10-2014
My Device: Z30
My Carrier: Bell

Re: How to get rid of "Open Application" popup window

I followed the links that you gave me.  I did the following but it's still not working. My index.html pgae has the following:

<script type="text/javascript" src="js/index.js"></script>
<ul> <li style="margin-top:10px;"><a href="" onclick="Invoke.adobeReaderPdf_2011();" id="adobeReaderPdf_2011">2011</a></li> </ul>

  my index.js file contains the following code:

var app = {
    // Application Constructor
    initialize: function() {
        this.bindEvents();
    },
    // Bind Event Listeners
    //
    // Bind any events that are required on startup. Common events are:
    // 'load', 'deviceready', 'offline', and 'online'.
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    // deviceready Event Handler
    //
    // The scope of 'this' is the event. In order to call the 'receivedEvent'
    // function, we must explicity call 'app.receivedEvent(...);'
    onDeviceReady: function() {
        app.receivedEvent('deviceready');
    },
    // Update DOM on a Received Event
    receivedEvent: function(id) {
        var parentElement = document.getElementById(id);
        var listeningElement = parentElement.querySelector('.listening');
        var receivedElement = parentElement.querySelector('.received');

        listeningElement.setAttribute('style', 'display:none;');
        receivedElement.setAttribute('style', 'display:block;');

        console.log('Received Event: ' + id);
    }
};

var Invoke = {
    adobeReaderPdf_2011: function() {
        var request = {
            target: "com.rim.bb.app.adobeReader",
            action: "bb.action.OPEN",
            type: "application/pdf",
            uri: "file:///accounts/1000/invoke/docs/2011.pdf"
        };
        Invoke.invokeApp(request);
    },

	invokeApp: function(request) {
        blackberry.invoke.invoke(
            request,
            function() {
                console.log('success');
            }, function(e) {
                console.log('error');
                console.log(e);
            }
        );
    }
};

 When I click the 2011 link, nothing happens. It should open up the 2011.pdf in Acrobat Reader App.

 

Can someone tell me what mistake I'm making. This is my first ever app.

 

Thanks in advance.

BlackBerry Development Advisor
Posts: 43
Registered: ‎01-11-2013
My Device: BlackBerry Z10
My Carrier: Rogers

Re: How to get rid of "Open Application" popup window

Just to confirm, did you install the invoke cordova plugin?

webworks plugin add com.blackberry.invoke

Also, can you see if there are any errors popping up in the WebInspector console?

 

--
Senior Systems Software Developer - Enterprise R&D

@roryboy

1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the like/thumbs up button below the post(s)
New Developer
Posts: 43
Registered: ‎03-10-2014
My Device: Z30
My Carrier: Bell

Re: How to get rid of "Open Application" popup window

Yes I have added com.blackberry.invoke plugin and no errors are popping up in WebInspector.  Although I see that when I click on the 2011  link the webpage flashes - as if page is refreshed. Is my filepath correct to PDF.  Here is my structure inside the www folder

www

index.html

|--js

     |--cordova.js, index.js

|--docs   

    |--2011.pdf

BlackBerry Development Advisor
Posts: 43
Registered: ‎01-11-2013
My Device: BlackBerry Z10
My Carrier: Rogers

Re: How to get rid of "Open Application" popup window

Try changing your onclick to:

<li style="margin-top:10px;"><a href="" onclick="Invoke.adobeReaderPdf_2011(event);" id="adobeReaderPdf_2011">2011</a></li>

 

And your function to:

var Invoke = {
    adobeReaderPdf_2011: function(ev) {
ev.preventDefault(); var request = { target: "com.rim.bb.app.adobeReader", action: "bb.action.OPEN", type: "application/pdf", uri: "file:///accounts/1000/invoke/docs/2011.pdf" }; Invoke.invokeApp(request); }, invokeApp: function(request) { blackberry.invoke.invoke( request, function() { console.log('success'); }, function(e) { console.log('error'); console.log(e); } ); } };

You have nothing stopping the default action of the link, which is to load whatever it is linked to. passing the event and preventing the default action should stop the reload. I didn't notice it missing the first time. More details on this at MDN https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault

 

Not sure that will fix the problem, but it should stop the page from reloading which will allow you to further debug the issue.

 

--
Senior Systems Software Developer - Enterprise R&D

@roryboy

1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the like/thumbs up button below the post(s)
New Developer
Posts: 43
Registered: ‎03-10-2014
My Device: Z30
My Carrier: Bell

Re: How to get rid of "Open Application" popup window

Yes that stoped reloading of the page. But still no errors in WebInspector and file is not opening.

New Developer
Posts: 43
Registered: ‎03-10-2014
My Device: Z30
My Carrier: Bell

Re: How to get rid of "Open Application" popup window

I added the alert('1') to the onclick event just to see if I see the pop-up at least.

 

<li style="margin-top:10px;"><a href="" onclick="alert('1');Invoke.adobeReaderPdf_2011(event);" id="adobeReaderPdf_2011">2011</a></li>

  And I see the alert pop-up with 1 but no sign of .pdf file.

New Developer
Posts: 105
Registered: ‎06-11-2013
My Device: DEVELOPER
My Carrier: vodafone

Re: How to get rid of "Open Application" popup window

Hi. There should be an option for hiding the feature. You can do that with the help of javascript

******Blackberry Developer*******---Built for the Kill-----
#######Developer of @Sudoku#########
New Developer
Posts: 43
Registered: ‎03-10-2014
My Device: Z30
My Carrier: Bell

Re: How to get rid of "Open Application" popup window

I installed the sample app called Invoker https://github.com/blackberry/BB10-WebWorks-Samples/tree/WebWorks-2.0/Invocation/Invoker/www and it work on my BB 10. This application opens the file file:///accounts/1000/shared/documents/Getting Started with Adobe Reader.pdf. If you open up the File Manager on BB 10 or connect BB 10 to PC, this file is located in the documents folder.

 

Here is my structure inside the www folder

 

www

index.html

|--js

     |--cordova.js, index.js

|--docs  

    |--2011.pdf

 

If I change file:///accounts/1000/shared/documents/Getting Started with Adobe Reader.pdf to file:///accounts/1000/shared/documents/2001.pdf, I can open my 2001.pdf but if I change the path to file:///accounts/1000/docs/2001.pdf I cannot open the PDF. 

 

Here is my question, given the above folder structure what should be the path to the 2011.pdf file located in docs folder.

 

Thank you.