I want to open external url in device default browser. Like for android it should get open in chrome and for ios it should open in safari.
Initially when I tried window.open(url,"_system") it was working fine with android. When I tried in ios, it wasn't working.
After some research, I came to know that due to popup block nature of safari, it wasn't opening. Then I disabled the pop-up block setting. Still issue was there. Later I came to know that I need to install InAppBrowser plugin to make it workable.
Hence I followed below steps
ionic cordova plugin add cordova-plugin-inappbrowser
npm install --save @ionic-native/in-app-browser
Added provider in app.module.ts file
After installation of plugin, app started crashing on android device. (Not checked on ios).
I don't know the reason. If I remove the plugin, application is working but now I am not able to open url in android also.
Can anyone please tell me how to open external url in android and ios?
Configuration
1. ionic - v3
2. Angular - v6
3. cordova - v8
Here is solution that worked for me in V3 with App Browser Plugin
<button ion-button block clear (click)="openWebpage(url)">Open Webpage</button>
and the openWebpage method goes like this
openWebpage(url: string) {
const options: InAppBrowserOptions = {
zoom: 'no'
}
// Opening a URL and returning an InAppBrowserObject
const browser = this.inAppBrowser.create(url, '_self', options);
// Inject scripts, css and more with browser.X
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With