Ionic 3 - network-information plugin - Object(…) is not a function(…)

前端 未结 2 1498
挽巷
挽巷 2021-01-22 20:37

I need to implement network information plugin in an ionic 3 angular 4 project. I have installed a network plugin using

$ ionic cordova plugin add cordova-plugin         


        
相关标签:
2条回答
  • 2021-01-22 21:07

    Since the release of Ionic 4, Installing Ionic Native for Ionic 3 requires you to add @4 to get the latest compatible version. In this case, and all others involving Ionic 3, you should do it like this

    npm install @ionic-native/network@4
    

    for network,

    npm install --save @ionic-native/barcode-scanner@4 
    

    for Barcode Scanner,

    npm install --save @ionic-native/network@4, 
    npm install --save @ionic-native/bluetooth-le@4 
    

    for BluetoothLE.

    0 讨论(0)
  • The problem is that you are using the /ngx import which is for Ionic version 4. If you go read the changelog you will see that version 5 and up Requires Angular 7.1 and TypeScript 3.1.

    Try to downgrade plugin to 4.20.0 like this :

    npm uninstall @ionic-native/network

    then npm install @ionic-native/network@4.20.0

    And remove ngx in import like this : import { Network } from '@ionic-native/network';

    0 讨论(0)
提交回复
热议问题