xylar
xylar

Reputation: 7673

Cordova Console plugin stops working after page load

I have a Cordova 7.0.1 project which uses console plugin so that I can console.log() on iOS. The plugin works until a redirect e.g.

window.location.href = 'index.html';

At this point the console.log() stops working even though alert() still works. It's frustrating because the app is unresponsive at this point (trying to login) and it's a pain debugging with alerts.

In XCode console I have the following:

2017-06-12 15:01:14.828 APP [x:x] Session validated
2017-06-12 15:01:14.835 APP [x:x] Resetting plugins due to page load.
2017-06-12 15:01:15.491 APP [x:x] Finished load of: file:///Users/X/Library/Developer/CoreSimulator/Devices/X/data/Containers/Bundle/Application/X/APP.app/www/index.html

The "Session validated" is console.logged.

Upvotes: 1

Views: 103

Answers (1)

xylar
xylar

Reputation: 7673

My issue was CSP declaration as I had gap: in the wrong place. This is what I had:

<meta http-equiv="Content-Security-Policy"
      content="default-src 'self' 'unsafe-inline' *; style-src 'self' 'unsafe-inline' *; script-src 'self' 'unsafe-inline' *; img-src 'self' 'unsafe-inline' * data: gap:;">

and this is what I replaced it with:

<meta http-equiv="Content-Security-Policy"
      content="default-src 'self' data: gap: 'unsafe-inline' *; style-src 'self' 'unsafe-inline' *; script-src 'self' 'unsafe-inline' *; img-src 'self' 'unsafe-inline' * data:;">

Upvotes: 2

Related Questions