- 移动端使用WechatAuthSDK获取二维码,为什么onAuthGotQrcode一直没有被调用
https://developers.weixin.qq.com/doc/oplatform/Mobile_App/WeChat_Login/Login_via_Scan.html // WeChatModule.h #import <React/RCTBridgeModule.h> #import <React/RCTEventEmitter.h> #import <WechatAuthSDK.h> @interface WeChatModule : RCTEventEmitter<RCTBridgeModule, WechatAuthAPIDelegate> @property (nonatomic, strong) WechatAuthSDK* wxAuthSdk; @end // WeChatModule.m #import "WeChatModule.h" @implementation WeChatModule - (instancetype)init { self = [super init]; if (self) { self.wxAuthSdk = [[WechatAuthSDK alloc] init]; [self.wxAuthSdk setDelegate:self]; } return self; } RCT_EXPORT_MODULE(); RCT_EXPORT_METHOD(wxQRCodeLogin:(NSDictionary *)param :(RCTResponseSenderBlock)callback) { NSString *appId = [param objectForKey:@"appId"]; NSString *nonceStr = [param objectForKey:@"nonceStr"]; NSString *timeStamp = [param objectForKey:@"timeStamp"]; NSString *scope = [param objectForKey:@"scope"]; NSString *signature = [param objectForKey:@"signature"]; NSString *schemeData = [param objectForKey:@"schemeData"]; NSLog(@"===delegate: %@", _wxAuthSdk.delegate); [_wxAuthSdk StopAuth]; BOOL done = [_wxAuthSdk Auth:appId nonceStr:nonceStr timeStamp: timeStamp scope:scope signature:signature schemeData:schemeData]; callback(@[@(done)]); } - (void)onAuthGotQrcode:(UIImage *)image { NSLog(@"===onAuthGotQrcode"); NSData *imageData = UIImagePNGRepresentation(image); if (imageData == nil) { imageData = UIImageJPEGRepresentation(image, 1); } [self sendEventWithName:@"onAuthGotQrcode" body:@{@"qrCode": imageData}]; } //二维码被扫描 - (void)onQrcodeScanned { NSLog(@"===onQrcodeScanned"); [self sendEventWithName:@"onQrcodeScanned" body:@{}]; } //成功登录 - (void)onAuthFinish:(int)errCode AuthCode:(nullable NSString *)authCode { NSLog(@"===onAuthFinish"); [self sendEventWithName:@"onAuthFinish" body:@{@"authCode": authCode, @"errCode": @(errCode)}]; } - (NSArray<NSString *> *)supportedEvents { return @[@"onAuthGotQrcode", @"onQrcodeScanned", @"onAuthFinish"]; } @end 运行后,打印了,xcode的output中打印了如下结果: ===delegate: <WeChatModule: 0x2813afae0> ---getWeChatLoginQRCode callback //js 代码里也在callback被执行时打印了 但是===onAuthGotQrcode一直没有被打印,也没有显示任何错误,请问有人知道是什么问题吗? iOS 13.3,xcode14.2, WechatAuthSDK的sdkversion 2.0, "react-native-wechat-lib": "1.1.26"
2023-07-03 - 移动端使用WechatAuthSDK获取二维码,为什么onAuthGotQrcode一直没有被调用?
// WeChatModule.h #import <React/RCTBridgeModule.h> #import <React/RCTEventEmitter.h> #import <WechatAuthSDK.h> @interface WeChatModule : RCTEventEmitter<RCTBridgeModule, WechatAuthAPIDelegate> @property (nonatomic, strong) WechatAuthSDK* wxAuthSdk; @end // WeChatModule.m #import "WeChatModule.h" @implementation WeChatModule - (instancetype)init { self = [super init]; if (self) { self.wxAuthSdk = [[WechatAuthSDK alloc] init]; [self.wxAuthSdk setDelegate:self]; } return self; } RCT_EXPORT_MODULE(); RCT_EXPORT_METHOD(wxQRCodeLogin:(NSDictionary *)param :(RCTResponseSenderBlock)callback) { NSString *appId = [param objectForKey:@"appId"]; NSString *nonceStr = [param objectForKey:@"nonceStr"]; NSString *timeStamp = [param objectForKey:@"timeStamp"]; NSString *scope = [param objectForKey:@"scope"]; NSString *signature = [param objectForKey:@"signature"]; NSString *schemeData = [param objectForKey:@"schemeData"]; NSLog(@"===delegate: %@", _wxAuthSdk.delegate); [_wxAuthSdk StopAuth]; BOOL done = [_wxAuthSdk Auth:appId nonceStr:nonceStr timeStamp: timeStamp scope:scope signature:signature schemeData:schemeData]; callback(@[@(done)]); } - (void)onAuthGotQrcode:(UIImage *)image { NSLog(@"===onAuthGotQrcode"); NSData *imageData = UIImagePNGRepresentation(image); if (imageData == nil) { imageData = UIImageJPEGRepresentation(image, 1); } [self sendEventWithName:@"onAuthGotQrcode" body:@{@"qrCode": imageData}]; } //二维码被扫描 - (void)onQrcodeScanned { NSLog(@"===onQrcodeScanned"); [self sendEventWithName:@"onQrcodeScanned" body:@{}]; } //成功登录 - (void)onAuthFinish:(int)errCode AuthCode:(nullable NSString *)authCode { NSLog(@"===onAuthFinish"); [self sendEventWithName:@"onAuthFinish" body:@{@"authCode": authCode, @"errCode": @(errCode)}]; } - (NSArray<NSString *> *)supportedEvents { return @[@"onAuthGotQrcode", @"onQrcodeScanned", @"onAuthFinish"]; } @end 运行后,打印了,xcode的output中打印了如下结果: ===delegate: <WeChatModule: 0x2813afae0> ---getWeChatLoginQRCode callback //js 代码里也在callback被执行时打印了 但是===onAuthGotQrcode一直没有被打印,也没有显示任何错误,请问有人知道是什么问题吗? iOS 13.3,xcode14.2, WechatAuthSDK的sdkversion 2.0, "react-native-wechat-lib": "1.1.26",
2023-06-30 - 为什么wx.getChannelsLiveNoticeInfo返回直播status都是0?
通过wx.getChannelsLiveNoticeInfo获取视频号直播预告信息,然后wx.reserveChannelsLive第一个直播,再次通过wx.getChannelsLiveNoticeInfo查询时,第一个直播的状态还是0
2022-12-06 - 真机中webp不能显示,iOS/Android平台是全面支持webp吗?
根据文档基础款在2.9.0以上,即可支持webp。目前我遇到的问题是,iOS真机上webp不能显示,开发工具的模拟器中可以。 基础库版本是2.14.1 微信版本8.0.9/ iOS14.2 , 微信8.0.10/ iOS 13.3, 微信8.0.7/Android 9. ``` import xxxImage from '../../../assets/images/xxx.webp'; <Image className="xxx-image" src={xxxImage} mode="widthFix" webp /> ```
2021-08-15 - 上传多张图片前压缩,除了使用canvasToTempFilePath,有其他更好的方案吗?
压缩图片,看到很多例子都是用canvasToTempFilePath,但是这个在想上传多张图片的时候用`canvasToTempFilePath`感觉太重了,有没有其他更好的通过resize来压缩图片的方案呢?
2021-08-10 - 能否在公众号中通过unionid判断用户是否注册了一个微信开放平台帐号下的小程序(唯一的)?
能否在公众号中通过unionid判断用户是否注册了一个微信开放平台帐号下的小程序(唯一的)?
2021-08-06 - 请问wxa/msg_sec_check中有哪些关键词会被认为命中呢?
请问wxa/msg_sec_check中有哪些关键词会被认为命中呢?有关键词列表吗?
2021-08-05 - 公众号可以跳转到没有关联的小程序吗?
公众号跳转小程序是否都必须关联?可以跳转到没有关联的小程序吗?
2021-08-04 - 提交审核(审核中)的非个人类型小程序是否可以修改名字?
已发布过的非个人小程序,现在要发布新的版本,同时想要修改小程序的名字。 认证改名需要花多少时间?如果提交代码审核和认证改名同时进行,是否会影响代码审核?是否会影响认证改名?
2021-07-23