import * as Wechat from 'react-native-wechat'
之后,会出现
undefined is not a function (evaluating 'globalObject.haOwnProperty("Promise")')
程序崩溃,
ios 正常
好像是 es6-promisify 导致的……
我 fork 了一份,使用 bluebird 的 promisify 之后不再崩溃了。
我自己的使用的 api (登录和shareToSession)没有问题,但是不确定这么改会不会影响到其他 api,
暂时没 pr 回来。
确实有这个问题,升级到42以后android一直跑不起来,调试发现是es6-promisify的问题,比较诡异的是debug模式正常,关闭就跪。。。
同样的问题。
除了引入其他promiss,还有其他办法否?
题主能说下这个问题的解决方法吗,才接触rn
@bugmover
我 fork 了一份,使用 bluebird 的 promisify 之后不再崩溃了。
我自己的使用的 api (登录和shareToSession)没有问题,但是不确定这么改会不会影响到其他 api,
就是用 bluebird 的 promisify 替换了原来的同名方法
@hitbear518
你好,我把react-native-wechat 的package。json,的 es6-promisify 依赖移除后报了相同的错误,我是不是还漏了什么操作呢,下面是我的react-native-wecha的package,谢谢哦
{
"_args": [
[
{
"raw": "react-native-wechat",
"scope": null,
"escapedName": "react-native-wechat",
"name": "react-native-wechat",
"rawSpec": "",
"spec": "latest",
"type": "tag"
},
"/Users/gaomu/Documents/workspaces/chuming.zhuang/gitlab/client/app-client"
]
],
"_cnpm_publish_time": 1487733998178,
"_from": "react-native-wechat@latest",
"_id": "[email protected]",
"_inCache": true,
"_location": "/react-native-wechat",
"_nodeVersion": "6.6.0",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/react-native-wechat-1.9.0.tgz_1487733997869_0.1618565039243549"
},
"_npmUser": {
"name": "yorkie",
"email": "[email protected]"
},
"_npmVersion": "4.0.5",
"_phantomChildren": {},
"_requested": {
"raw": "react-native-wechat",
"scope": null,
"escapedName": "react-native-wechat",
"name": "react-native-wechat",
"rawSpec": "",
"spec": "latest",
"type": "tag"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npm.taobao.org/react-native-wechat/download/react-native-wechat-1.9.0.tgz",
"_shasum": "e455a0eacadbb1dd4e0280c85b0982d8412da2ab",
"_shrinkwrap": null,
"_spec": "react-native-wechat",
"_where": "/Users/gaomu/Documents/workspaces/chuming.zhuang/gitlab/client/app-client",
"author": {
"name": "Yorkie Liu",
"email": "[email protected]"
},
"bugs": {
"url": "https://github.com/weflex/react-native-wechat/issues"
},
"contributors": [
{
"name": "Yorkie Liu",
"email": "[email protected]"
},
{
"name": "Deng Yun",
"email": "[email protected]"
}
],
"dependencies": {
"events": "1.0.2"
},
"description": "react-native library for wechat app",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "e455a0eacadbb1dd4e0280c85b0982d8412da2ab",
"size": 6591869,
"noattachment": false,
"tarball": "http://registry.npm.taobao.org/react-native-wechat/download/react-native-wechat-1.9.0.tgz"
},
"gitHead": "b2e1f8d6a944dfa5c0fede157e9dfdeecaf7d732",
"homepage": "https://github.com/weflex/react-native-wechat#readme",
"keywords": [
"wechat",
"react",
"react-native",
"react-component",
"ios"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "yorkie",
"email": "[email protected]"
}
],
"name": "react-native-wechat",
"optionalDependencies": {},
"peerDependencies": {
"react-native": ">=0.40"
},
"publish_time": 1487733998178,
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/weflex/react-native-wechat.git"
},
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"version": "1.9.0"
}

我也遇到同样问题了,在Debug JS Remotely 模式下却正常,求解决!
@zhuangchuming 我看不懂你的错误报告……
你可以先依赖我 fork 的版本,应该就可以 build 成功了
@hitbear518 好的,我那个不是错误报告哦,是react-native-wechat的package.json文件,里面我把"dependencies": 的es6-promisify给去掉了,是不是还需要编译什么的?
@hitbear518 npm 好像不能下载依赖你的fork:
npm install hitbear518/react-native-wechat --save
@hitbear518 我直接用你的文件替换我本地的文件,然后安装 bluebird,使用的是微信支付,会报警告,然后直接返回了微信的回调。ios正常,微信支付不能使用。

@zhangweijie-cn
https://docs.npmjs.com/files/package.json#git-urls-as-dependencies
你能调得起微信支付吗 @hitbear518
@zhuangchuming
我没有用到,所以没有试
@hitbear518 微信支付是可以使用的,没问题。你修改了那个,React/RCTImageUtils.h的头文件我这边也是会找不到,所以我注释掉了
https://github.com/weflex/react-native-wechat/pull/189 看看这个PR能否解决掉这个问题?
@yorkie 应该不能吧……当时我试过升级 es6-promisify 到最新版
给一个示例代码,我这里编译是可以的~
es6-promisify升级到5.0.0了,还是不行
@yorkie
https://github.com/hitbear518/RNWechatBug
我新建了一个空的 RNProject,依赖了自己 fork 的 react-native-wechat(把 es6-promisify 升级到了5.0.0),然后 import * as Wechat from 'react-native-wechat',可以稳定重现 bug
@hitbear518 Your solution is working for me. But we could also try to remove the browserify dependency completely. I've done that for the react-native-weibo already:
https://github.com/reactnativecn/react-native-weibo/pull/28
@flavordaaave good solution, awesome! could you please make the same for this repo?
@yorkie
I removed promisify to fix this and made a pr #194 ,
but I only tested registerApp, isWXInstalled, sendAuthRequest, shareToSession;
and there's some extra diff because of yarn and prettier,
what should I do next?
尝试一下 1.9.2 版本 :)
Most helpful comment
我 fork 了一份,使用 bluebird 的 promisify 之后不再崩溃了。
我自己的使用的 api (登录和shareToSession)没有问题,但是不确定这么改会不会影响到其他 api,
暂时没 pr 回来。