【问题标题】:Ionic 4 Open Native Settings Plugin not workingIonic 4 打开本机设置插件不起作用
【发布时间】:2019-08-26 14:30:10
【问题描述】:

我在我的 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')
          });

        });

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

有什么建议吗??谢谢

【问题讨论】:

  • 您也应该将其添加到您的app.module.ts 中。
  • @NajamusSaqib 感谢您的建议。但我设法通过将插件版本降级为下面的答案来解决问题

标签: cordova ionic-framework ionic4 ionic-native


【解决方案1】:

在我的案例中发现了问题。由于我使用的是 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';

【讨论】:

    猜你喜欢
    • 2019-01-08
    • 1970-01-01
    • 2023-03-11
    • 2019-11-16
    • 2018-04-10
    • 2017-09-26
    • 1970-01-01
    • 1970-01-01
    • 2018-02-19
    相关资源
    最近更新 更多