I know it's been an issue before but I'm still having this issue. Whether I add "window" or not is still the same (although a different error message). And I've also made it sure that it will only run after the device ready event has been received.
I've created the app using Phonegap CLI and built it on Phonegap Build.
I added this on my config.xml:
<gap:plugin name="cordova-plugin-networkinterface" source="npm" />
Here's what my javascript look like:
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
alert('Received Event: ' + id);
setTimeout(function(){
try{
networkinterface.getIPAddress(function (ip) {
alert("IP: "+ip);
function(error){
alert("IP Error: "+error);
});
}catch(e){alert(e)}
}, 1000);
}
};
I know it's been an issue before but I'm still having this issue. Whether I add "window" or not is still the same (although a different error message). And I've also made it sure that it will only run after the device ready event has been received.
I've created the app using Phonegap CLI and built it on Phonegap Build.
I added this on my config.xml:
<gap:plugin name="cordova-plugin-networkinterface" source="npm" />
Here's what my javascript look like:
I also tried it on runkit with the same result as mine which I got from NPM: https://runkit.com/589d9741aa6f95001497501d/589d9741aa6f95001497501e
Can you please take a closer look on what's causing this?
Thank you very much!