Push doesn't work (Error: Could not get)

我与影子孤独终老i 提交于 2019-12-23 05:38:16

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/23291727/push-doesnt-work-error-could-not-get

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!