记录ionic 最小化应用时所遇的问题

ionic3与ionic4最小化插件安装不一样:

ionic3安装方法:

$ ionic cordova plugin add cordova-plugin-appminimize
$ npm install --save @ionic-native/app-minimize@4

并在app.module.ts中 注入依赖:

import { AppMinimize } from '@ionic-native/app-minimize';

......

  providers: [
    AppMinimize,
    .....
    ],

 

应用时:

import { Platfrom } from 'ionic-angular';
import { AppMinimize } from '@ionic-native/app-minimize';


constructor(private platform: Platform, private appMinimize: AppMinimize) { }

...

this.platform.registerBackButtonAction(() => {
   this.appMinimize.minimize();
});

 

 

ionic4安装方法

ionic cordova plugin add cordova-plugin-appminimize
npm install @ionic-native/app-minimize

 

并在app.module.ts中 注入依赖:

import { AppMinimize } from '@ionic-native/app-minimize/ngx';

......

  providers: [
    AppMinimize,
    .....
    ],

 

应用时:

import { Platfrom } from '@ionic/angular';
import { AppMinimize } from '@ionic-native/app-minimize/ngx';


constructor(private platform: Platform, private appMinimize: AppMinimize) { }

...

this.platform.registerBackButtonAction(() => {
   this.appMinimize.minimize();
});

 

posted @ 2019-06-06 14:43  liliyou  阅读(182)  评论(0编辑  收藏  举报