首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >离子3-本机AppPrefences plugin_not_installed误差

离子3-本机AppPrefences plugin_not_installed误差
EN

Stack Overflow用户
提问于 2018-04-24 13:43:04
回答 1查看 657关注 0票数 2

这让我发疯了。因此,我为这个项目创建了一个专用的项目,下面是我所做的。

创建空白离子项目。这是控制台输出

代码语言:javascript
复制
[DEBUG] Reason for not using local CLI: BASE_DIRECTORY_NOT_FOUND
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: 'E:\\Project\\Ionic', local: false, binPath:
        'C:\\Users\\yandi\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath:
        'C:\\Users\\yandi\\AppData\\Roaming\\npm\\node_modules\\ionic\\dist\\index.js' }
[DEBUG] Daemon found (pid: 11712)

? What starter would you like to use: blank
√ Creating directory .\AppPreferences - done!
√ Downloading and extracting blank starter - done!

? Would you like to integrate your new app with Cordova to target native iOS and Android? Yes
√ Personalizing ionic.config.json and package.json - done!
> ionic integrations enable cordova --quiet
√ Downloading integration cordova - done!
[DEBUG] Integration files downloaded to C:\Users\yandi\AppData\Local\Temp\ionic-integration-cordova (files: config.xml,
        resources)
[DEBUG] Blacklist:
√ Copying integrations files to project - done!
[OK] Added cordova integration!

Installing dependencies may take several minutes.

> npm i
√ Running command - done!

得到需要的科多瓦插件。控制台输出

代码语言:javascript
复制
√ Creating .\www directory for you - done!
> cordova plugin add cordova-plugin-app-preferences --save
Adding cordova-plugin-app-preferences to package.json

Saved plugin info for "cordova-plugin-app-preferences" to config.xml

获得所需的npm包。控制台输出

代码语言:javascript
复制
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ @ionic-native/app-preferences@4.7.0
added 1 package in 26.305s

将插件添加到我的app.module中

代码语言:javascript
复制
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';

import { AppPreferences } from '@ionic-native/app-preferences';

@NgModule({
  declarations: [
    MyApp,
    HomePage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    AppPreferences,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

这是我的page.ts

代码语言:javascript
复制
import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';

import { AppPreferences } from '@ionic-native/app-preferences';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController, public appPreferences: AppPreferences, public platform: Platform) {}

  checkPref(){
    this.platform.ready().then((success) => {
      this.appPreferences.show().then((success) => {
        alert(success);
      }, (fail) => {
        alert(fail);
      });
    }, (fails) => {
      console.log(fails);
    });
  }

}

page.html

代码语言:javascript
复制
<ion-content padding>
  <button ion-button (click)="checkPref()">Check Plugin</button>
</ion-content>

当我点击它的时候,它写着"plugin_not_installed“

那我做错什么了?这真的让我很沮丧。我已经弄清楚了我的应用程序上的所有东西,这是我需要的最后一点

**更新:在Ionic Dev应用程序的帮助下,我正在我的手机(小米米4i)上服务。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-04-24 14:02:47

cordova-plugin-app-preferences不受Ionic DevApp支持。

所以你需要把它构建成一个apk,并作为一个真正的应用程序运行。

有关支持的插件的完整列表,请参阅离子DevApp文档

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50003248

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档