inAppBrowser Plugin not working

Moderator: Support

Image3D
Posts: 10
Joined: Sat Feb 27, 2021 8:09 pm

inAppBrowser Plugin not working

Post by Image3D »

I am using the following code for open an pdf on the cordova inAppBrowser:

pdf2Render = "http://www.pdf995.com/samples/pdf";

var target = "_system";

Code: Select all

var options = "location=yes,hidden=yes,beforeload=yes,closebuttoncaption=CloseenableViewportScale=yes,fullscreen=no";

debugger;
window.open(pdf2Render, target, options);

On iOS device it should open the pdf file on Safari, but it does not.

Can you help?

Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

Re: inAppBrowser Plugin not working

Post by Serhii Kulibaba »

Hello,

You don't use the inAppBrowser in this example.

Please see the following links on how to use inAppBrowser in your project.

JQM apps: https://docs.appery.io/docs/cordova-jqu ... appbrowser

Ionic 1 apps: https://docs.appery.io/docs/cordova-ionic-inappbrowser

Ionic 4/5 apps: https://ionicframework.com/docs/native/in-app-browser
Here is a tutorial on how to include Ionic plugins into your project: https://docs.appery.io/docs/ionic-4-sol ... from-ionic

Image3D
Posts: 10
Joined: Sat Feb 27, 2021 8:09 pm

Re: inAppBrowser Plugin not working

Post by Image3D »

Hi Serhii,

I think I found the problem. Building .ipa with library version v5.2 using the code bellow to open the system browser does not work on iOS.

Code: Select all

window.open(pdf2Render, target, options);

but building .ipa with library version v5.1 the code above works, ( I am using the same Cordova plugin in both versions), and opens the safari browser with the provided url.

Any idea what is causing the problem in library version v.2 ?

Regards Joni

Image3D
Posts: 10
Joined: Sat Feb 27, 2021 8:09 pm

Re: inAppBrowser Plugin not working

Post by Image3D »

I just did an exercise using the JQM apps: https://docs.appery.io/docs/cordova-jqu ... appbrowser tutorial, exported as a Xcode Project and build it with Version 12.2 .

Choosing System Browser it does not open the Safari browser as expected. It opens in the same WKWebView. ( see attached images).

We need a work around. Any ideas?

Regards Joni

Attachments
Opens URL in the same WKWebView
Opens URL in the same WKWebView
Screen Shot 2021-03-15 at 08.35.17.png (142.34 KiB) Viewed 1656 times
System Bowser selected
System Bowser selected
Screen Shot 2021-03-15 at 08.34.18.png (41.09 KiB) Viewed 1656 times
Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

Re: inAppBrowser Plugin not working

Post by Serhii Kulibaba »

Hello,

Have you selected the latest Cordova version in your project? Please see here a solution how to fix the issue with "WKWebView" https://blog.appery.io/2020/07/importan ... age-error/

Image3D
Posts: 10
Joined: Sat Feb 27, 2021 8:09 pm

Re: inAppBrowser Plugin not working

Post by Image3D »

Setting the cordova-plugin-ionic-webview gives a build error ( see log attached)..

Attachments
build.log.zip
(15.23 KiB) Downloaded 3 times
Image3D
Posts: 10
Joined: Sat Feb 27, 2021 8:09 pm

Re: inAppBrowser Plugin not working

Post by Image3D »

Found that when our App is tested from inside iOS Appery Tester window.open(pdf2Render, target, options); works just fine, but when we call it from an device installed version on the same device it does no opens the system browser.

What is different in Appery tester that allows window.open to open the Safari browser ?

Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

Re: inAppBrowser Plugin not working

Post by Serhii Kulibaba »

Hello,

You are right. Please use the in-app browser. Apple rejects simple window.open

What project type do you use here, Ionic 1, Ionic 4 or JQM?

Image3D
Posts: 10
Joined: Sat Feb 27, 2021 8:09 pm

Re: inAppBrowser Plugin not working ( Solved)

Post by Image3D »

HI, review calling code for the following configuration:

  • Library version set to v5.2
    Cordova Plugins
  • InAppBrowser 4.00
  • OpenUrlExt 1.02[/list]

Used the following code with the OpenUrlExt Cordova Plugin (pdf2Render is the url to open)

if (isMobile.iOS() || isMobile.Android()) {
OpenUrlExt.open(pdf2Render,
function() {
console.log("ok");
},
function() {
console.log("ko");
});
} else {
window.open(pdf2Render, '_system');
}

Also using cordova.InAppBrowser.open(pdf2Render, '_system'); works. Important: test Cordova plugins calls only on device.

Hope the solution help others developersto call URL on device browsers.

Best Regards,

Joni

Galyna Abramovych
Site Admin
Posts: 68
Joined: Tue Mar 22, 2016 6:03 pm

Re: inAppBrowser Plugin not working

Post by Galyna Abramovych »

Thanks for sharing this!

Post Reply