在 React Native 中使用 PubNub [英] Using PubNub with React Native
问题描述
有没有人能够将 PubNub 与 React Native 集成?
Has anybody been able to integrate PubNub with React Native?
PubNub 支持团队告诉我使用 pubnub_browserify 包,它应该可以工作.但是,当我执行 require('pubnub_browserify')
时,我收到一个错误,提示找不到 http
模块:
The PubNub support team told me to use the pubnub_browserify package and it should work. However when I do require('pubnub_browserify')
I get an error that the http
module could not be found:
无法从/Users/jfender/Documents/Workspace/KaiwaReact/node_modules/pubnub_browserify/browserify_node/pubnub.js 解析模块 http:无效目录/Users/node_modules/http
运行 npm install http --save
不会改变错误.
Running npm install http --save
doesn't change the error.
我使用的是 Node v5.1.0、npm 3.3.12 和 React Native 0.14.2.
I am using Node v5.1.0, npm 3.3.12 and React Native 0.14.2.
这是我的 package.json:
Here is my package.json:
{
"name": "KaiwaReact",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start"
},
"dependencies": {
"eslint": "^1.10.0",
"eslint-plugin-react": "^3.9.0",
"parse": "^1.6.9",
"parse-react": "^0.5.0",
"pubnub_browserify": "^1.0.2",
"react-native": "^0.14.2"
}
}
推荐答案
我能够集成它.我使用了标准的 javascript 包.但是,我确实需要对其进行一些修改.主要是删除所有对window"和abort"的引用.一旦我删除了那些,我就可以走了.
I was able to integrate it. I used the standard javascript package. However, I did need to modify it a bit. Mostly to remove all the references to 'window' and to 'abort'. Once I removed those, I was good to go.
这篇关于在 React Native 中使用 PubNub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!