cordova - SSE 无法通过使用域名在 android 中运行
问题描述
我正在使用来自 Ajax “<a href="https://username%40gmail.com:password@home.myopenhab.org/rest/events?topics=smarthome/" rel="nofollow noreferrer">https:// /username%40gmail.com:password@home.myopenhab.org/rest/events?topics=smarthome/" 使用 Cordova 在客户端应用程序中获取 SSE。它在 IOS 上工作正常,但在 android 上不工作。对于相同的 URL,如果我给像“ http://192.168.0.1/rest/events?topics=smarthome/ ”这样的IP,它在IOS和android上都可以正常工作。
我的代码是这样的
var eventSource = new EventSource(" +“url”+ /rest/events?topics=smarthome/*");
eventSource.addEventListener(‘message’, function (eventPayload)
{
//not entering here.
}
解决方案
推荐阅读
- javascript - 点击主页时如何点击p-breadcrumb
- java - 在java中将docx转换为pdf
- drupal-8 - 在 Drupal 8. Drupal 商务。如何根据产品字段隐藏视图(实体参考 - 分类)
- angular - querySelectorAll 的打字稿类型
- json - 如何在 Shell 脚本中使用正则
- javascript - 如何在悬停 a-frame 元素时使用其 ID 调用 javascript 函数?
- git - '\' 不是内部或外部命令、可运行程序或批处理文件。发出 git rev-list 时
- spotfire - 新的 SharePoint 列表列在 SpotFire 中不可见(SharePoint 连接器,不是 OData)
- javascript - Javascript 控制台记录扩展异常
- react-admin - React Admin 中默认排序、分页参数名称和逻辑不一致