I have an Ionic 2 app that needs to open another app called Bank ID (https://play.google.com/store/apps/details?id=com.bankid.bus&hl=en) but I just can’t seem to find a way that works for Android (it works on iOS).
The app I am trying to open has the following documentation on doing this:
When the BankID app is installed the schema “bankid” is registered in the operating system. When the bankid schema is requested from the browser the operating system launches the BankID app. The URL works in Android, iOS and Windows 10 Mobile when the built-in web browser is used. The URL works in PCs with all commonly used browsers. Some differences exist on different platforms. The URL syntax is:
bankid:///?autostarttoken=[TOKEN]&redirect=[RETURNURL]
Note that the redirect parameter must be last in the parameter list. The autostarttoken, filehash and rpref parameters are optional. Note that the parameter names must be lower case.
So within my code I test if the app exists and if it does I go to the “bankid://”. But when testing the app on my device nothing happens/the app doesn’t open. Neither does the browser. Nothing happens at all.
this.launchExternalApp('bankid://', 'com.bankid.bus', 'bankid://', 'https://www.bankid.com/', 'https://itunes.apple.com/us/app/bankid-säkerhetsapp/id433151512', 'https://play.google.com/store/apps/details?id=com.bankid.bus');
launchExternalApp(iosSchemaName: string, androidPackageName: string, appUrl: string, httpUrl: string, httpUrliOS: string, httpUrlAndroid: string) {
let app: string;
if (Device.platform === 'iOS') {
console.log("Device is iOS");
app = iosSchemaName;
} else if (Device.platform === 'Android') {
console.log("Device is Android");
app = androidPackageName;
} else {
console.log("Device is not mobile");
const browser = this.iab.create(httpUrl);
return;
}
AppAvailability.check(app).then(
() => { // success callback
console.log("App is available, going to it");
const browser = this.iab.create(appUrl, '_system');
},
() => { // error callback
if (Device.platform === 'iOS') {
console.log("iOS App is not available, going to URL");
const browser = this.iab.create(httpUrliOS);
}
else {
console.log("Android app is not available, going to URL");
const browsertwo = this.iab.create(appUrl, '_system');
}
}
);
}
Anyone tried this before? Do you have a better method that actually works on android? Any suggestions would be great.