我正在使用ionicapp 2,我有一个屏幕,当用户单击归档时,我们想显示计算器,以便用户可以执行计算。
有办法可以做到吗?
问候,raaj
安装插件
ionic plugin add cordova-plugin-inappbrowser
ionic plugin add cordova-plugin-appavailability
ionic plugin add cordova-plugin-device
感谢他们导入
import { InAppBrowser, AppAvailability, Device } from 'ionic-native';
现在尝试这个
launchExternalApp(iosSchemaName: string, androidPackageName: string, appUrl: string, httpUrl: string, username: string) {
let app: string;
if (Device.device.platform === 'iOS') {
app = iosSchemaName;
} else if (Device.device.platform === 'Android') {
app = androidPackageName;
} else {
let browser = new InAppBrowser(httpUrl + username, '_system');
return;
}
AppAvailability.check(app).then(
(success) => { // success callback
let browser = new InAppBrowser(appUrl + username, '_system');
},
(error) => { // error callback
let browser = new InAppBrowser(httpUrl + username, '_system');
}
);
}
openInstagram(username: string) {
this.launchExternalApp('instagram://', 'com.instagram.android', 'instagram://user?username=', 'https://www.instagram.com/', username);
}
openTwitter(username: string) {
this.launchExternalApp('twitter://', 'com.twitter.android', 'twitter://user?screen_name=', 'https://twitter.com/', username);
}
openFacebook(username: string) {
this.launchExternalApp('fb://', 'com.facebook.katana', 'fb://profile/', 'https://www.facebook.com/', username);
}