"Network Information" cordova plugin not working - javascript

I am currently working on a rather large PhoneGap project using a handful of cordova plugins and I'm experiencing dificulties using the Network Information plgin to retrieve the connection type of the device.
It should be noted that I'm using the command line tool to build my PhoneGap project, not Adobe's "Build" service.
The versions of the phonegap and cordova cli tools are the following:
% phonegap -v
4.2.0-0.23.0
% cordova -v
4.2.0
Here is the list of plugins currently in use:
% phonegap plugins
com.darktalker.cordova.screenshot 0.1.0 "Screenshot"
nl.x-services.plugins.socialsharing 4.3.14 "SocialSharing"
org.apache.cordova.console 0.2.13 "Console"
org.apache.cordova.device 0.3.0 "Device"
org.apache.cordova.inappbrowser 0.6.0 "InAppBrowser"
org.apache.cordova.network-information 0.2.15 "Network Information"
Here is the code responsible for using the plugin, it's located in a much larger object and is only called when I open to a certain page of the project:
checkDeviceConnexion:function(){
require(['cordova', 'cordova_plugins'], function(cordova){
checkConnexion();
});
function networkConnexion(){
if (navigator.connection.type == 'none'){ //Connection.NONE
return false;
}
return true;
}
function checkConnexion(){
if (!networkConnexion()){
app.showMsgError(tradu[lang]['msg-error-connexion']);
}
}
}
I'm doing my tests on android therefor I'm using adb as a mean to debug the application. When I run the code above, this is what I get:
I/chromium(12465): [INFO:CONSOLE(1145)] "Uncaught TypeError: Cannot read property 'type' of undefined", source: file:///android_asset/www/js/app.js (1145)
I scrapped and rebuilt the android project several times to make sure that all plugins were properly copied but it didn't help.
What's even more puzzling is that the output of the adb hints that somehow somewhere the network manager should be working properly as shown here:
D/CordovaNetworkManager(21764): Connection Type: wifi
D/CordovaNetworkManager(21764): Connection Extra Info: "atelier8"
But I'm unable to see the connection property in the navigator object.
Has anyone experienced similar issues? Any idea on how to fix this problem?
Thanks in advance for any tip or answer.

Related

Getting a 404 error when trying to setup WebStorm IDE JavaScript debugger for a create-react-app

When following an article entitled, "Debugging React apps created with Create React App in WebStorm", the Debugger says it's connected to the JetBrains IDE Chrome Extension, but I can't get breakpoints to execute when using port 3000 and when I try to use the default debug port 63342 a 404 error is shown.
Here is a recording of my settings in Chrome and Webstorm 2016.2 IDE when trying to debug: http://recordit.co/MQ3LICuUIc
Steps Taken:
I've created a new JS debug configuration with the name 'ERS React Debug', the browser set to Chrome, and I've tried using the following URLs in the configuration:
http://localhost:3000/
http://localhost:3000/ers_react/public/index.html
http://localhost:63342/ers_react/public/index.html
(YT video I watched used the debug port, which is what is in my recording)
I also setup the mapping to webpack:///src as recommend in the article.
Default ReactJS app created with create-react-app is designed to be hosted on webpack server started with react-scripts start, that builds the application and starts the server. You won't be able to open this application on the simple built-in webserver (localhost:63342).
To be able to debug modern React app, you need upgrading Webstorm to the most recent version - debugging will work out of the box. Fot Webstorm 2016.2, you can try specifying URL mappings... For "react-scripts": "1.0.17", it should be http://localhost:3000/static/js/full/path to project, like http://localhost:3000/static/js/C:/WebstormProjects/untitled if the project path is C:/WebstormProjects/untitled should work:
Note that you would need to refresh the browser page to get breakpoints in code executed on pagfe loading hit

ngCamera not working on iOS

I have been trying to get my camera to work on iOS for a couple days now. I found this Ionic Cordova Camera not working, but when I get to the part that says to put this into the command line "cordova plugin add org.apache.cordova.camera" it returns this error "Error: Registry returned 404 for GET on https://registry.npmjs.org/org.apache.cordova.camera" I tried finding why it was returning that error but can't find a good response.
I also did the add before and still nothing.
EDIT I was able to do a little more digging and found an error "Error: Can't find variable: Camera"
I should add that this works just fine on android but iOS wants nothing to do with the camera.
run below command in your working directory. That will add camera plugin in your projects.--save flag will save your plugin in config.xml file.
cordova plugin add cordova-plugin-camera --save
cordova plugin add cordova-plugin-camera

Console log is not working with Netbeans (Android emulator and Cordova)

Everything works fine except there is no output when calling console.log(...) in the Browser window log (Netbeans).
I created a new HTML5 (Cordova Application) project in Netbeans.
I start the android emulator (Intel Atom x86 API Level 19. Galaxy Nexus. With Use Host GPU option checked). Then build/run the project BUILD SUCCESSFUL (total time: 10 seconds) and I can see the app running in the emulator with the 'Device is ready' text blinking.
But there is not console log output. I have made sure the Debugger Console plugin is selected (inside the project properties). I also have added android:debuggable="true" inside <application .../> tag in AndroidManifest.xml file. And still no console log output.
I have also tested with API 21 and still no ouput from console.log
What am I missing?
I'm using cordova 4.3.0, Netbeans 8.0.2, Java version: 1.8.0_45, Apache Ant 1.9.4.
Thanks in advance.
UPDATE: I can see the log entry with DDMS but since I'm using Use Host GPU, Logcat is spammed with an error and by the looks of it, the filter doesn't work as expected and sometimes it stops logging for whatever reason (DDMS). At least I know the console.log call works inside the javascript. By the looks of it, DDMS is buggy.
I think I found out why Netbeans isn't picking up any log output.
Debugger console seems to only work for Xcode and/or maybe Netbeans isn't configured to get any log from LogCat. Cordova redirects console.log calls to their respective platform logger. That's why I can see the log entry just fine with adb logcat -s "CordovaLog" (CordovaLog being the tag to filer).
Edit:
Netbeans doesn't connect fast enough and it doesn't show you earlier logs. I recommend to use Chrome remote debugging instead of Netbeans.
While this is not a direct answer to your question, NetBeans personally recommends that you use Chrome with their extension for HTML5 projects:
https://netbeans.org/kb/docs/webclient/html5-gettingstarted.html
Hope that works for you!
2 things that might help: Make sure you have Cordova plugin called "Debugger Console" in your project
Second thing try to use NetBeans dev build from here . The dev build contains importnant fix - IDs of core Cordova plugins has been changed recently and as a result NetBeans could be removing these plugins from build when building the project.

Error initializing Cordova: undefined

I've developed a web app using cordova 3.5.0 and it runs fine in my Z10, however there is an error when starting the app that says
After pressing OK app works fine. I cannot use Web Inspector because the error is thrown before it is available.
This is what I use to get the app up and running
cordova build
cordova run blackberry --devicepass 1234 --keystorepass 12345678
I couldn't find any solution using cordova directly, therefore I've decide to migrate to webworks and problem is gone.
Migration was quite easy as webworks is cordova based, I've created a new project with
webworks create myproject
webworks pluging add org.apache.cordova.device
I've overwritten the entire www folder with my development, updated the config.xml
and the magic comes with
webworks run --devicepass 1234
No initializing error anymore

'Failed to get tabs for debugging' when trying to debug NodeJs with chrome debugger for Eclipse

I have struggled this for couple of days without any success, please help me out.
What I am seeking is to find a better IDE for editing and debugging Node.js based JavaScript server code. I have successfully installed Eclipse IDE for JavaScript and followed link https://github.com/joyent/node/wiki/Using-Eclipse-as-Node-Applications-Debugger installed Chrome debugger for Eclipse.However, when I tried to debug I encountered an error saying 'Failed to get tabs for debugging'
Here are the steps what I did:
Installed Node.js v0.10.0
Installed Eclipse IDE for JavaScript
Installed Chrome debugger for Eclipse by following https://github.com/joyent/node/wiki/Using-Eclipse-as-Node-Applications-Debugger
Create a debug configuration under WebKit Protocol (refer to bottom picture)
Create a JavaScript project in Eclipse
Create a JavaScript source file in the project
Open a Ubuntu terminal and run the JavaScript source file: node debug test1.js
In Eclipse try debug with the custom debug configuration and the error happens.
PS: my Ubuntu is 12.04 64bit; NodeJs remote debug port is default 5858
Please help me on this, what did I missing from the steps?
Step #4 is incorrect. Should be "Standalone V8 VM".

Categories