possible unhandled promise rejection id(1)
支付成功 但是没有回调onResp
注:已配置配置了URL Types 和LSApplicationQueriesSchemes
@damly 可以给出一段重现bug的代码么?
try {
WeChat.registerApp(this.appId);
let result = await WeChat.pay(
{
partnerId: options.partnerId, // 商家向财付通申请的商家id
prepayId: options.prepayId, // 预支付订单
nonceStr: options.nonceStr, // 随机串,防重发
timeStamp: options.timeStamp, // 时间戳,防重发
package: options.package, // 商家根据财付通文档填写的数据和签名
sign: options.sign // 商家根据微信开放平台文档对数据做的签名
}
);
console.log('>>>>>>>>>>> pay',result); //未执行
alert("Pay success!"); //未执行
success();
} catch (error) {
console.log('Pay for failure!'); //未执行
alert("Pay for failure!"); //未执行
faile(error);
}
@damly 可以帮忙debug一下这里么:https://github.com/weflex/react-native-wechat/blob/master/index.js#L203 看看这个函数有没有调用
@yorkie 目标机iOS 10系统
return new Promise((resolve, reject) => {
WeChat.pay(data, (result) => {
if (result) reject(result);
});
emitter.on('PayReq.Resp', (resp) => {
console.log('>>>>>>>>>>> PayReq.Resp'); //未执行
alert(pay);
const result = resp.errCode;
if (result === 0) {
resolve(resp.returnKey);
} else {
reject(result);
}
});
哪里有简单的 react-native-wechat的支付 example 可以做对比测试的?
可以分享和登录么?
登录和分享 暂时没有用 没有写相关的代码
那应该是签名问题,请核对下你的ID后,在重新build一下!
@yorkie
能正常分享,并且能正常返回
那支付么?
@yorkie 能支付成功 但是就是不回调onResp
但是就是不回调onResp
是说 await 之后,不会执行是么?
@yorkie 是的
我是这样解决的问题:
RCTWeChat.h 添加
RCTWeChat.m
去掉
AppDelegate.m 添加
@damly 这个问题最后解决了么?
解决了
@yorkie 谢谢分享。这个patch是不是应该merge到master上去?不回调也复现在了我发起sendAuthRequest的操作上了。BTW, 分享到朋友圈是可以成功的。
@damly 你想要把你的comments变成pr么?
请问这个问题解决了吗?
感谢分享
Most helpful comment
我是这样解决的问题:
RCTWeChat.h 添加
RCTWeChat.m
去掉
然后添加
static RCTWeChat * instance = nil; //放在@implementation RCTWeChat前
@synchronized(self) {
if (!instance) {
instance = [[self alloc] init];
}
}
return instance;
}
@synchronized(self) {
if (!instance) {
instance = [super allocWithZone:zone];
}
}
return instance;
}
return self;
}
{
NSLog(@"+++++++++++++++ handleOpenURL %@", url);
return [WXApi handleOpenURL:url delegate:self];
}
AppDelegate.m 添加
{
return [[RCTWeChat shareInstance] handleOpenURL: url];
}