1

I'm pulling my hair out on this one. I'm using phonegap 3.4 to build an iOS app. When I build the project and run in the simulator, I want to view the output of console.log in the xcode debug window, but it's not working. I've installed the org.apache.cordova.console plugin, but no luck. I see some normal debug output like "Resetting plugins due to page load" but none of my console.logs appear. Any ideas?

And this did not solve my issue: console.log is not working in iOS Phonegap App even after adding the console plugin

Community
  • 1
  • 1
Jeremy
  • 163
  • 3
  • 14

4 Answers4

2

try alert();
it is basically the same as console.log();
but you need to install different plugins: org.apache.cordova.dialogs

i dont have iphone nor mac so i can't guarantee it will work on them. But in one android device that i tried, when the console.log() fails. Alert() succeeds.

There are 2 types of alert:

  1. alert('text'); //this is actually javascript
  2. navigator.notification.alert(message, alertCallback, [title], [buttonName]) //this is phonegap function

In my case. i have only need to use the first one.
further documentation on the second alert function is below:
https://cordova.apache.org/docs/en/3.0.0/cordova_notification_notification.md.html#notification.alert

i hope it will work on xcode too.

vdj4y
  • 2,649
  • 2
  • 21
  • 31
0

Make sure you install the console plugin. While Android is able to do this out of the box, logging to console is otherwise not supported on iOS:

krik
  • 539
  • 4
  • 6
0

The solution is: call logger.__onDeviceReady function from your deviceready listener function:

function onDeviceReady() {
    if (window.cordova.logger) {
        window.cordova.logger.__onDeviceReady();
    }
}

document.addEventListener('deviceready', onDeviceReady, false);
Bo Persson
  • 90,663
  • 31
  • 146
  • 203
Paradise
  • 558
  • 6
  • 17
-4

Try to use "document.write" instead.

Anjy786
  • 145
  • 8