Ionic 4 Open Native Settings 插件不工作

Ionic 4 Open Native Settings Plugin not working

我在 ionic 4 项目中使用“open-native-settings”。基于文档 https://ionicframework.com/docs/native/open-native-settings#usage 我的实现如下。

myclass.module.ts:

import { OpenNativeSettings } from '@ionic-native/open-native-settings/ngx';


providers:[
    OpenNativeSettings
  ],

myclass.ts 文件:

import { OpenNativeSettings } from '@ionic-native/open-native-settings/ngx';
import { Platform } from 'ionic-angular';

constructor(
    private openNativeSettings: OpenNativeSettings,
    private _platform: Platform) {}

方法内部

this._platform.ready().then(() => {
          // open settings
          this.openNativeSettings.open("about").then(val => {
            console.log('success')
          });

        });

我没有收到任何编译错误。但是当我调用该方法时,应用程序显示以下运行时错误。

有什么建议吗??谢谢

在我的案例中发现了问题。由于我使用的是 ionic v4.x,我将 open-native-settings 插件版本降级为 4.x

npm install @ionic-native/open-native-settings@4

然后在没有 /ngx 的情况下导入。其他代码同上

import { OpenNativeSettings } from '@ionic-native/open-native-settings';