Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native: tried calling Network.type, but the Network plugin is not installed. #1335

Closed
gabeta opened this issue Apr 6, 2017 · 11 comments
Closed

Comments

@gabeta
Copy link

gabeta commented Apr 6, 2017

I use network information on my project.
Ionic info:
Cordova CLI: 6.5.0
Ionic Framework Version: 2.2.0
Ionic CLI Version: 2.2.2
Ionic App Lib Version: 2.2.1
Ionic App Scripts Version: 1.1.4
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 8.1
Node Version: v7.7.3
Xcode version: Not installed

I have followed the instructions in doc.
https://ionicframework.com/docs/native/network/

$ ionic plugin add cordova-plugin-network-information
$ npm install --save @ionic-native/network

But when i make console.log(Network.type) this return null and i this message

Native: tried calling Network.type, but the Network plugin is not installed.
Install the Network plugin: 'ionic plugin add cordova-plugin-network-information

Thanks for helping me to solve this BUG.

@matheusleite
Copy link

Same issue here!

@ihadeed
Copy link
Collaborator

ihadeed commented May 17, 2017

Is this issue with Ionic Native 2.x?

@gabeta
Copy link
Author

gabeta commented May 19, 2017

Yes ionic native 2.8.1

@ihadeed
Copy link
Collaborator

ihadeed commented May 19, 2017

Make sure you have the latest version of cordova-plugin-network-information installed. There is nothing wrong with the Ionic Native definitions. (just checked the v2.x repo that has the code for ionic-native@2.9.0)

cordova plugin rm cordova-plugin-network-information
cordova-plugin add cordova-plugin-network-information@latest

@ihadeed ihadeed closed this as completed May 19, 2017
@thiphariel
Copy link

thiphariel commented Jan 30, 2018

You can reopen this because the issue is still there on @ionic-native/core@4.5.3

@viking2917
Copy link

I have the same error. Re-installed plugin per the above and still get this error when running in browser via "ionic serve"

ionic.native.js:17007 Native: tried calling Network.type, but the Network plugin is not installed.
ionic.native.js:17012 Install the Network plugin: 'ionic plugin add cordova-plugin-network-information'

Cordova plugin list shows the plugin is in fact installed. This is with Ionic V1.

ionic info

cli packages: (/Users/markwatkins/.nvm/versions/node/v8.9.4/lib/node_modules)

@ionic/cli-utils  : 1.19.1
ionic (Ionic CLI) : 3.19.1

global packages:

cordova (Cordova CLI) : 8.0.0 
Gulp CLI              : CLI version 3.9.1 Local version 3.9.1

local packages:

Cordova Platforms : android 6.4.0 ios 4.5.4
Ionic Framework   : ionic1 1.3.3

System:

Android SDK Tools : 26.1.1
ios-deploy        : 1.9.2 
Node              : v8.9.4
npm               : 5.6.0 
OS                : macOS High Sierra
Xcode             : Xcode 9.2 Build version 9C40b 

Environment Variables:

ANDROID_HOME : /Users/markwatkins/Library/Android/sdk

Misc:

backend : pro

Marks-Air-2:newBookship4 markwatkins$ ionic cordova plugin list

cordova plugin ls
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-apprate 1.3.0 "AppRate"
cordova-plugin-camera 4.0.2 "Camera"
cordova-plugin-contacts 3.0.1 "Contacts"
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-dialogs 2.0.1 "Notification"
cordova-plugin-facebook4 1.7.4 "Facebook Connect"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-globalization 1.0.9 "Globalization"
cordova-plugin-google-analytics 1.8.3 "Google Universal Analytics Plugin"
cordova-plugin-inappbrowser 2.0.2 "InAppBrowser"
cordova-plugin-ionic-keyboard 2.0.5 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 1.1.16 "cordova-plugin-ionic-webview"
cordova-plugin-media 5.0.2 "Media"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.1 "StatusBar"
cordova-plugin-whitelist 1.3.3 "Whitelist"
cordova-support-google-services 1.0.0 "cordova-support-google-services"
phonegap-plugin-barcodescanner 7.0.2 "BarcodeScanner"
phonegap-plugin-push 2.1.2 "PushPlugin"

@polfernandez
Copy link

this issue should be opened. I still have it

@viking2917
Copy link

viking2917 commented Feb 7, 2018

(After fooling with the below again, I cannot get any variation to work, I think this is the wrong track. I think I am missing something in how to use this plugin in Ionic V1. My usage goes something like:

.run(function($ionicPlatform, $location, $state, $rootScope, $ionicPopup, $http, $timeout, $ionicHistory, $ionicLoading, $cordovaPush, $cordovaMediaPlugin, $cordovaNetwork) {
....
    $ionicPlatform.ready(function() {
	console.log($cordovaNetwork.type);
==> Error

I noticed a line in another issue (#357) which might be a clue:

@ihadeed said...

Hey there,
This plugin (and a few others) is instance based. You need to do something like the following:
var transfer = new $cordovaTransfer();
transfer.upload(...);

(instead of the traditional syntax of $cordovaTransfer.upload())

And based on this (#86) I am working if Network is one of those instance based plugins? (Incidentally I can find no documentation about which Ionic Native plugins are instance based and so don't use the normal provider syntax reference pattern...)

So I haven't had a chance to try it (worked around this by not using the plugin) but I wonder if something along the lines of

var network = new $cordovaNetwork() 

or

var transfer = new IonicNative.Network();

then...
network.type ....

might work?

@polfernandez
Copy link

@viking2917 I tried it but without luck. It still gives the same error msg.

Thanks!

@viking2917
Copy link

@polfernandez me too. I really only needed it to detect whether an internet connection was present and a simple workaround of

navigator.onLine

seemed to do the trick for me, with no need for the plugin.

@polfernandez
Copy link

@viking2917 thanks for the hint. However, I would like to get the connection speed and I did not find any other alternative.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants