How can I create a link button in my cordova app, which is redirecting to my app on iOS/Android/Amazon App Store depending on the device?
I have tried the following code, it gets in the iOS if clause, but it doesn't redirect me, neither gives an error:
if(window.cordova && window.device) {
if (device.platform.toUpperCase() === 'IOS') {
window.open("https://itunes.apple.com/gb/[OBFUSCATED]");
} else if (device.platform.toUpperCase() === 'ANDROID') {
window.open("https://play.google.com/store/apps/details?id=[OBFUSCATED]");
} else {
window.open("https://www.amazon.co.uk/[OBFUSCATED]");
}
}
I figured it out:
IOS: itms-apps://itunes.apple.com/app/[appId]
Android: market://details?id=[appPackageId]
Amazon: amzn://apps/android?p=[appPackageId]
you can use Inappbrowser plugin.
Install inappbrowser plugin with following command:
cordova plugin add cordova-plugin-inappbrowser
and use following in your code:
var isAndroid = navigator.userAgent.match(/android/i) ? true : false;
var isIOS = navigator.userAgent.match(/(ipod|ipad|iphone)/i) ? true : false;
if(isIOS){
window.open("https://itunes.apple.com/gb/app/[OBFUSCATED]","_system");
} else if (isAndroid) {
window.open("https://play.google.com/store/apps/details?id=[OBFUSCATED]", "_system");
} else {
window.open("https://www.amazon.co.uk/[OBFUSCATED]", "_system");
}
Hope it will help you.
Ping comment if you stuck anywhere.
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