我是 Ionic 2 和周围一切的新手。我正在尝试设置我的第一个移动应用程序:触摸一个按钮我将打开 native 导航(例如,Android 版 Google map )。我已经安装了 launchnavigator
插件:
ionic plugin add uk.co.workingedge.phonegap.plugin.launchnavigator
在 cremony.ts 页面内:
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { LaunchNavigator, LaunchNavigatorOptions } from 'ionic-native';
@Component({
selector: 'page-ceremony',
templateUrl: 'ceremony.html'
})
export class Ceremony {
constructor(public navCtrl: NavController) {
}
navigate() {
let options: LaunchNavigatorOptions = {
start: ""
};
LaunchNavigator.navigate("London, UK", options)
.then(
success => alert('Launched navigator'),
error => alert('Error launching navigator: ' + error)
);
}
}
构建npm run build
并使用 ionic upload
将其上传到 IonicView .
我已经按照 this link 中的建议做了所有事情但运气不同。
但是当我在 Ionic View 中单击按钮(一个简单的 <button ion-button (click)="navigate()">Navigate</button>
在 ceremy.html 中)时,出现错误:Error launghing navigator: plugin_not_installed
.
我检查了项目,plugins
目录包含 uk.co.workingedge.phonegap.plugin.launchnavigatorlooks
目录。所以我看package.json
和 config.xml
我已经添加了值 uk.co.workingedge.phonegap.plugin.launchnavigator
在cordovaPlugins
和标记 <plugin name="uk.co.workingedge.phonegap.plugin.launchnavigator" spec="~3.2.1" />
在widget
根。 npm run build
, ionic upload
但没有任何改变。
我的错误在哪里?
最佳答案
新答案,你的项目有问题。您是否修改了 index.html 文件?它还包括 cordova.js 吗?如果是,您使用的是哪个版本的 Ionic 和 Cordova?
我用您的确切代码制作了这个示例应用程序,它在 iOS 和 Android 上都能完美运行:https://github.com/roblouie/navigator-plugin-test
iOS录屏:https://giphy.com/gifs/xTiN0EEQV82aIXWnQI 刚刚在 Android 上抓取了一张图片,但效果相同:
请尝试来自github的项目。
关于android - 未安装 LaunchNavigator Ionic2 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42334380/