推送无效(错误:无法获取) [英] Push doesn't work (Error: Could not get)
问题描述
尝试使用Ratchet的push.js,但不起作用. 我在控制台中拥有什么:
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)
所有这些来自真实设备测试(iOS 7.1)的控制台数据,包装器都是Cordova CLI 3.4.1-0.1.0.
All this console data from real device tests (iOS 7.1), wrapper is Cordova CLI 3.4.1-0.1.0.
文件booking.html存在,像这样的本地野生动物园失败
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)
没有出现.
推荐答案
push.js
不支持file://协议.
push.js
does not support file:// protocol.
Ratchet使用XHR请求来获取内部的其他页面 应用.出于安全考虑,现代浏览器无法使用XHR 在本地打开文件时(也使用file://协议)请求; 因此,直接作为文件打开时,Ratchet不起作用.一种 常见的解决方案是简单地从本地提供文件 服务器.实现此目的的一种简便方法是运行python -m SimpleHTTPServer来提供当前目录中的文件 到
http://localhost:<port>
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
使用Cordova和Ratchet似乎是一个常见问题.
It seems like this is a common issue with using Cordova and Ratchet.
这篇关于推送无效(错误:无法获取)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!