Skip to content

Commit

Permalink
fix compile issue
Browse files Browse the repository at this point in the history
  • Loading branch information
JarvanMo committed May 15, 2023
1 parent 3cc9241 commit b9ed814
Showing 1 changed file with 49 additions and 51 deletions.
100 changes: 49 additions & 51 deletions ios/Classes/FluwxPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,24 @@ @implementation FluwxPlugin {
NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;


- (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar methodChannel:(FlutterMethodChannel *)flutterMethodChannel {
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
FlutterMethodChannel *channel =
[FlutterMethodChannel methodChannelWithName:@"com.jarvanmo/fluwx"
binaryMessenger:[registrar messenger]];
FluwxPlugin *instance = [[FluwxPlugin alloc] initWithChannel:channel];
[registrar addApplicationDelegate:instance];
[registrar addMethodCallDelegate:instance channel:channel];
}

- (instancetype)initWithChannel:(FlutterMethodChannel *)channel {
self = [super init];
if (self) {
_fluwxRegistrar = registrar;
_isRunning = NO;
_channel = channel;
_qrauth = [[WechatAuthSDK alloc] init];
_qrauth.delegate = self;
_isRunning = NO;
thumbnailWidth = 150;
_channel = flutterMethodChannel;
_attemptToResumeMsgFromWxFlag = false;
_attemptToResumeMsgFromWxFlag = NO;
#if WECHAT_LOGGING
[WXApi startLogByLevel:WXLogLevelDetail logBlock:^(NSString *log) {
[self logToFlutterWithDetail:log];
Expand All @@ -88,7 +96,7 @@ - (instancetype)initWithRegistrar:(NSObject <FlutterPluginRegistrar> *)registrar

- (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
_isRunning = YES;

if ([@"registerApp" isEqualToString:call.method]) {
[self registerApp:call result:result];
} else if ([@"isWeChatInstalled" isEqualToString:call.method]) {
Expand Down Expand Up @@ -157,16 +165,6 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
}
}

+ (void)registerWithRegistrar:(nonnull NSObject<FlutterPluginRegistrar> *)registrar {
<#code#>
}


+ (void)registerWithRegistrar:(nonnull NSObject<FlutterPluginRegistrar> *)registrar {
<#code#>
}


- (void)openWeChatInvoice:(FlutterMethodCall *)call result:(FlutterResult)result {

NSString *appId = call.arguments[@"appId"];
Expand Down Expand Up @@ -209,7 +207,7 @@ - (void)registerApp:(FlutterMethodCall *)call result:(FlutterResult)result {
}

BOOL isWeChatRegistered = [WXApi registerApp:appId universalLink:universalLink];

#if WECHAT_LOGGING
if(isWeChatRegistered) {
[WXApi checkUniversalLinkReady:^(WXULCheckStep step, WXCheckULStepResult* result) {
Expand All @@ -219,7 +217,7 @@ - (void)registerApp:(FlutterMethodCall *)call result:(FlutterResult)result {
}

#endif

result(@(isWeChatRegistered));
}

Expand All @@ -230,8 +228,8 @@ - (void)checkWeChatInstallation:(FlutterMethodCall *)call result:(FlutterResult)
- (void)openWeChatCustomerServiceChat:(FlutterMethodCall *)call result:(FlutterResult)result {
NSString *url = call.arguments[@"url"];
NSString *corpId = call.arguments[@"corpId"];


WXOpenCustomerServiceReq *req = [[WXOpenCustomerServiceReq alloc] init];
req.corpid = corpId; //企业ID
req.url = url; //客服URL
Expand Down Expand Up @@ -271,7 +269,7 @@ - (void)handlePayment:(FlutterMethodCall *)call result:(FlutterResult)result {
req.timeStamp = timeStamp;
req.package = packageValue;
req.sign = sign;

[WXApi sendReq:req completion:^(BOOL done) {
result(@(done));
}];
Expand Down Expand Up @@ -305,7 +303,7 @@ - (void)handleLaunchMiniProgram:(FlutterMethodCall *)call result:(FlutterResult)
miniProgramType = WXMiniProgramTypePreview;
}


WXLaunchMiniProgramReq *launchMiniProgramReq = [WXLaunchMiniProgramReq object];
launchMiniProgramReq.userName = userName;
launchMiniProgramReq.path = (path == (id) [NSNull null]) ? nil : path;
Expand Down Expand Up @@ -834,7 +832,7 @@ - (void)onResp:(BaseResp *)resp {
@"state": [FluwxStringUtil nilToEmpty:authResp.state]

};

if(_channel != nil){
[_channel invokeMethod:@"onAuthResponse" arguments:result];
}
Expand All @@ -845,29 +843,29 @@ - (void)onResp:(BaseResp *)resp {

} else if ([resp isKindOfClass:[WXChooseInvoiceResp class]]) {
//TODO 处理发票返回,并回调Dart

WXChooseInvoiceResp *chooseInvoiceResp = (WXChooseInvoiceResp *) resp;


NSArray *array = chooseInvoiceResp.cardAry;

NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:array.count];


for (int i = 0; i< array.count; i++) {
WXInvoiceItem *item = array[i];


NSDictionary *dict = @{@"app_id":item.appID, @"encrypt_code":item.encryptCode, @"card_id":item.cardId};
[mutableArray addObject:dict];
}

NSError *error = nil;

NSData *jsonData = [NSJSONSerialization dataWithJSONObject:mutableArray options:NSJSONWritingPrettyPrinted error: &error];

NSString *cardItemList = @"";

if ([jsonData length] && error == nil) {
cardItemList = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
}
Expand All @@ -879,11 +877,11 @@ - (void)onResp:(BaseResp *)resp {
type: @(chooseInvoiceResp.type),
@"cardItemList":cardItemList
};

if(_channel != nil){

[_channel invokeMethod:@"onOpenWechatInvoiceResponse" arguments:result];

}
} else if ([resp isKindOfClass:[WXSubscribeMsgResp class]]) {

Expand All @@ -893,22 +891,22 @@ - (void)onResp:(BaseResp *)resp {
if(openid != nil && openid != NULL && ![openid isKindOfClass:[NSNull class]]){
result[@"openid"] = openid;
}

NSString *templateId = subscribeMsgResp.templateId;
if(templateId != nil && templateId != NULL && ![templateId isKindOfClass:[NSNull class]]){
result[@"templateId"] = templateId;
}

NSString *action = subscribeMsgResp.action;
if(action != nil && action != NULL && ![action isKindOfClass:[NSNull class]]){
result[@"action"] = action;
}

NSString *reserved = subscribeMsgResp.action;
if(reserved != nil && reserved != NULL && ![reserved isKindOfClass:[NSNull class]]){
result[@"reserved"] = reserved;
}

UInt32 scene = subscribeMsgResp.scene;
result[@"scene"] = @(scene);
if(_channel != nil){
Expand All @@ -934,7 +932,7 @@ - (void)onResp:(BaseResp *)resp {


// @"extMsg":miniProgramResp.extMsg == nil?@"":miniProgramResp.extMsg

if(_channel != nil){
[_channel invokeMethod:@"onLaunchMiniProgramResponse" arguments:result];

Expand All @@ -959,7 +957,7 @@ - (void)onResp:(BaseResp *)resp {

} else if ([resp isKindOfClass:[WXOpenCustomerServiceResp class]])
{

WXOpenCustomerServiceResp *customerResp = (WXOpenCustomerServiceResp *) resp;
NSDictionary *result = @{
description: [FluwxStringUtil nilToEmpty:customerResp.description],
Expand All @@ -975,7 +973,7 @@ - (void)onResp:(BaseResp *)resp {
// 相关错误信息
}else if ([resp isKindOfClass:[WXOpenBusinessViewResp class]])
{

WXOpenBusinessViewResp *openBusinessViewResp = (WXOpenBusinessViewResp *) resp;
NSDictionary *result = @{
description: [FluwxStringUtil nilToEmpty:openBusinessViewResp.description],
Expand Down Expand Up @@ -1011,7 +1009,7 @@ - (void)onResp:(BaseResp *)resp {
[_channel invokeMethod:@"onPayResponse" arguments:result];
}
} else if ([resp isKindOfClass:[WXNontaxPayResp class]]) {

}
#endif
}
Expand All @@ -1023,7 +1021,7 @@ - (void)onReq:(BaseReq *)req {
//onWXLaunchFromWX
ShowMessageFromWXReq *showMessageFromWXReq = (ShowMessageFromWXReq *) req;
WXMediaMessage *wmm = showMessageFromWXReq.message;


NSDictionary *result = @{
@"extMsg": wmm.messageExt,
Expand All @@ -1033,7 +1031,7 @@ - (void)onReq:(BaseReq *)req {
};

[FluwxDelegate defaultManager].extMsg= wmm.messageExt;

if (_isRunning) {
[_channel invokeMethod:@"onWXShowMessageFromWX" arguments:result];
} else {
Expand All @@ -1047,7 +1045,7 @@ - (void)onReq:(BaseReq *)req {
} else if ([req isKindOfClass:[LaunchFromWXReq class]]) {
LaunchFromWXReq *launchFromWXReq = (LaunchFromWXReq *) req;
WXMediaMessage *wmm = launchFromWXReq.message;


NSDictionary *result = @{
@"extMsg": wmm.messageExt,
Expand All @@ -1057,7 +1055,7 @@ - (void)onReq:(BaseReq *)req {
};

[FluwxDelegate defaultManager].extMsg= wmm.messageExt;

if (_isRunning) {
[_channel invokeMethod:@"onWXLaunchFromWX" arguments:result];
} else {
Expand All @@ -1068,8 +1066,8 @@ - (void)onReq:(BaseReq *)req {
};
}

if(channel != nil){
[channel invokeMethod:@"onWXShowMessageFromWX" arguments:result];
if(_channel != nil){
[_channel invokeMethod:@"onWXShowMessageFromWX" arguments:result];
}
}

Expand Down

0 comments on commit b9ed814

Please sign in to comment.