console.log not working in an iOS PhoneGap 3.0 app

后端 未结 8 1387
庸人自扰
庸人自扰 2020-12-14 02:00

I am upgrading an app from PhoneGap 1.9 to PhoneGap 3.0. The console.log() function is not working anymore. Previously, the ouput was written in the XCode console. What\'s t

相关标签:
8条回答
  • 2020-12-14 03:04

    It turned out, at least in my case, that deviceready function for the logger was not getting called. The final line in logger.js.

    document.addEventListener("deviceready", logger.__onDeviceReady, false);
    

    The solution (or really a work-around) is to call the logger.__onDeviceReady function from your deviceready listener function:

    function onDeviceReady() {
        if (window.cordova.logger) {
            window.cordova.logger.__onDeviceReady();
        }
    }
    
    document.addEventListener('deviceready', onDeviceReady, false);
    
    0 讨论(0)
  • 2020-12-14 03:05

    Add the console plugin as in the Sam's answer and ensure to include cordova.js on every page otherwise no plugin works.

    When using phonegap plugins I was adding phonegap.js in script tag then I noticed that plugins (any) works on index.html page only. When I changed phonegap.js to cordova.js, plugins(notification, camera etc) started working on rest of the pages. If this helps anyone.

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