android - 未安装 LaunchNavigator Ionic2 插件

标签 android cordova ionic2

我是 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.jsonconfig.xml我已经添加了值 uk.co.workingedge.phonegap.plugin.launchnavigatorcordovaPlugins 和标记 <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 上抓取了一张图片,但效果相同:Android Pic

请尝试来自github的项目。

关于android - 未安装 LaunchNavigator Ionic2 插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42334380/

相关文章:

android - `doInBackground()` 不接受类型为 void 的 `AsyncTask`?

android - 无法解析方法 show(android.app.FragmentManager, java.lang.String)

input - 使用 Ionic 2 将焦点设置在输入上

cordova - Firebase如何通过 native Facebook应用程序对用户进行身份验证

android - Cordova/Phonegap 文件传输插件

angular - 如何在数据准备好后关闭 Loader

angular - 防止按钮双击ionic2

javascript - Phonegap 的本地存储可靠性

Android OpenGL ES 纹理大小 2 的幂

javascript - Jquery .text() 在带有 cordova 的 ios 上无法正常工作