Вопрос

Trying to use Ratchet's push.js, but doesn't work. What I have in console:

[Error] Error: Could not get: file:///var/mobile/Applications/337585D8-89E1-4810-AB37-0A6DD2DA3A34/Gustav.app/www/booking.html
failure (ratchet.js, line 446)
onreadystatechange (ratchet.js, line 371)

If you will tap link like ten times you start to receive this:

[Error] TypeError: 'undefined' is not an object (evaluating 'cacheMapping[PUSH.id].url')
cachePush (ratchet.js, line 202)
PUSH (ratchet.js, line 392)
touchend (ratchet.js, line 258)

All this console data from real device tests (iOS 7.1), wrapper is Cordova CLI 3.4.1-0.1.0.

File booking.html exist, native safari failure like this

[Error] Failed to load resource: The requested URL was not found on this server. (menu.html, line 0)

doesn't appear.

Это было полезно?

Решение

push.js does not support file:// protocol.

Ratchet uses XHR requests to fetch additional pages inside the application. Due to security concerns, modern browsers prevent XHR requests when opening files locally (aka using the file:// protocol); consequently, Ratchet does not work when opened directly as a file. A common solution to this is to simply serve the files from a local server. One convenient way to achieve this is to run python -m SimpleHTTPServer to serve up the files in the current directory to http://localhost:<port>

Also see this issue and this issue submitted on Github

It seems like this is a common issue with using Cordova and Ratchet.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top