Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
c40981c1
提交
c40981c1
authored
4月 26, 2023
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix no_pay bug.
上级
8e878a79
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
289 行增加
和
401 行删除
+289
-401
Podfile.lock
example/ios/Podfile.lock
+8
-8
FluwxAuthHandler.h
ios/Classes/FluwxAuthHandler.h
+1
-0
FluwxAuthHandler.m
ios/Classes/FluwxAuthHandler.m
+1
-1
FluwxPlugin.m
ios/Classes/FluwxPlugin.m
+265
-12
FluwxResponseHandler.h
ios/Classes/FluwxResponseHandler.h
+0
-54
FluwxResponseHandler.m
ios/Classes/FluwxResponseHandler.m
+0
-316
WXApiRequestHandler.h
ios/Classes/WXApiRequestHandler.h
+2
-1
WXApiRequestHandler.m
ios/Classes/WXApiRequestHandler.m
+3
-2
fluwx.podspec
ios/fluwx.podspec
+9
-7
没有找到文件。
example/ios/Podfile.lock
浏览文件 @
c40981c1
...
...
@@ -2,13 +2,13 @@ PODS:
- Flutter (1.0.0)
- fluwx (0.0.1):
- Flutter
- fluwx/pay (= 0.0.1)
- fluwx/pay (0.0.1):
- fluwx/
no_
pay (= 0.0.1)
- fluwx/
no_
pay (0.0.1):
- Flutter
-
WechatOpenSDK-XCFramework (~> 2.0.2)
-
"OpenWeChatSDKNoPay (~> 2.0.2+1)"
- integration_test (0.0.1):
- Flutter
-
WechatOpenSDK-XCFramework
(2.0.2)
-
OpenWeChatSDKNoPay
(2.0.2)
DEPENDENCIES:
- Flutter (from `Flutter`)
...
...
@@ -17,7 +17,7 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
-
WechatOpenSDK-XCFramework
-
OpenWeChatSDKNoPay
EXTERNAL SOURCES:
Flutter:
...
...
@@ -29,10 +29,10 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
fluwx:
6e8b0aa360e5fc3591cbe4b304763d9d316673af
fluwx:
143bf1458e1a46493eb0bc18deb1ee90037f4c30
integration_test: 13825b8a9334a850581300559b8839134b124670
WechatOpenSDK-XCFramework: acdeeda129efbef9532bca8a10c24e1b4b8c7d69
OpenWeChatSDKNoPay: 59a9628a746352bb400329cb7f12e6dc7096bf6e
PODFILE CHECKSUM: beab77b38961de946f08660e554f80ac174dc842
COCOAPODS: 1.1
1.3
COCOAPODS: 1.1
2.1
ios/Classes/FluwxAuthHandler.h
浏览文件 @
c40981c1
...
...
@@ -7,6 +7,7 @@
#import "FluwxPlugin.h"
#import "WXApiRequestHandler.h"
#import "WechatAuthSDK.h"
#import <WXApi.h>
@class
FluwxStringUtil
;
...
...
ios/Classes/FluwxAuthHandler.m
浏览文件 @
c40981c1
...
...
@@ -26,7 +26,7 @@ FlutterMethodChannel *_fluwxMethodChannel = nil;
SendAuthReq
*
authReq
=
[[
SendAuthReq
alloc
]
init
];
authReq
.
scope
=
call
.
arguments
[
@"scope"
];
authReq
.
state
=
(
call
.
arguments
[
@"state"
]
==
(
id
)
[
NSNull
null
])
?
nil
:
call
.
arguments
[
@"state"
];
[
WXApi
sendAuthReq
:
authReq
viewController
:
vc
delegate
:
[
FluwxResponseHandler
defaultManager
]
completion
:^
(
BOOL
success
)
{
[
WXApi
sendAuthReq
:
authReq
viewController
:
vc
delegate
:
self
completion
:^
(
BOOL
success
)
{
result
(
@
(
success
));
}];
}
...
...
ios/Classes/FluwxPlugin.m
浏览文件 @
c40981c1
#import "FluwxPlugin.h"
#import "FluwxResponseHandler.h"
#import "FluwxStringUtil.h"
#import "FluwxAuthHandler.h"
#import "FluwxShareHandler.h"
#import "FluwxDelegate.h"
@interface
FluwxPlugin
()
<
WXApiManagerDelegate
>
#import <WXApi.h>
#import <WXApiObject.h>
@interface
FluwxPlugin
()
<
WXApiDelegate
>
@property
(
strong
,
nonatomic
)
NSString
*
extMsg
;
@end
typedef
void
(
^
FluwxWXReqRunnable
)(
void
);
@implementation
FluwxPlugin
const
NSString
*
errStr
=
@"errStr"
;
const
NSString
*
errCode
=
@"errCode"
;
const
NSString
*
openId
=
@"openId"
;
const
NSString
*
type
=
@"type"
;
const
NSString
*
lang
=
@"lang"
;
const
NSString
*
country
=
@"country"
;
const
NSString
*
description
=
@"description"
;
FluwxAuthHandler
*
_fluwxAuthHandler
;
FluwxShareHandler
*
_fluwxShareHandler
;
BOOL
_isRunning
;
...
...
@@ -32,7 +42,6 @@ FlutterMethodChannel *channel = nil;
binaryMessenger
:[
registrar
messenger
]];
FluwxPlugin
*
instance
=
[[
FluwxPlugin
alloc
]
initWithRegistrar
:
registrar
methodChannel
:
channel
];
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
[[
FluwxResponseHandler
defaultManager
]
setMethodChannel
:
channel
];
[
registrar
addApplicationDelegate
:
instance
];
#if TARGET_OS_IPHONE
...
...
@@ -48,9 +57,8 @@ FlutterMethodChannel *channel = nil;
_fluwxShareHandler
=
[[
FluwxShareHandler
alloc
]
initWithRegistrar
:
registrar
];
_isRunning
=
NO
;
channel
=
flutterMethodChannel
;
[
FluwxResponseHandler
defaultManager
].
delegate
=
self
;
#if
def
WECHAT_LOGGING
#if WECHAT_LOGGING
[
WXApi
startLogByLevel
:
WXLogLevelDetail
logBlock
:
^
(
NSString
*
log
)
{
[
self
logToFlutterWithDetail
:
log
];
}];
...
...
@@ -158,7 +166,7 @@ FlutterMethodChannel *channel = nil;
BOOL
isWeChatRegistered
=
[
WXApi
registerApp
:
appId
universalLink
:
universalLink
];
#if
def
WECHAT_LOGGING
#if WECHAT_LOGGING
if
(
isWeChatRegistered
)
{
[
WXApi
checkUniversalLinkReady
:
^
(
WXULCheckStep
step
,
WXCheckULStepResult
*
result
)
{
NSString
*
log
=
[
NSString
stringWithFormat
:
@"%@, %u, %@, %@"
,
@
(
step
),
result
.
success
,
result
.
errorInfo
,
result
.
suggestion
];
...
...
@@ -196,6 +204,7 @@ FlutterMethodChannel *channel = nil;
}
}
#ifndef NO_PAY
-
(
void
)
handlePayment
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
...
...
@@ -231,6 +240,7 @@ FlutterMethodChannel *channel = nil;
result
(
@
(
done
));
}];
}
#endif
-
(
void
)
handleLaunchMiniProgram
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
NSString
*
userName
=
call
.
arguments
[
@"userName"
];
...
...
@@ -316,19 +326,19 @@ FlutterMethodChannel *channel = nil;
-
(
BOOL
)
application
:(
UIApplication
*
)
application
openURL
:(
NSURL
*
)
url
sourceApplication
:(
NSString
*
)
sourceApplication
annotation
:(
id
)
annotation
{
return
[
WXApi
handleOpenURL
:
url
delegate
:
[
FluwxResponseHandler
defaultManager
]
];
return
[
WXApi
handleOpenURL
:
url
delegate
:
self
];
}
// NOTE: 9.0以后使用新API接口
-
(
BOOL
)
application
:(
UIApplication
*
)
app
openURL
:(
NSURL
*
)
url
options
:(
NSDictionary
<
NSString
*
,
id
>
*
)
options
{
return
[
WXApi
handleOpenURL
:
url
delegate
:
[
FluwxResponseHandler
defaultManager
]
];
return
[
WXApi
handleOpenURL
:
url
delegate
:
self
];
}
-
(
BOOL
)
application
:(
UIApplication
*
)
application
continueUserActivity
:(
NSUserActivity
*
)
userActivity
restorationHandler
:(
void
(
^
)(
NSArray
*
_Nonnull
))
restorationHandler
{
return
[
WXApi
handleOpenUniversalLink
:
userActivity
delegate
:
[
FluwxResponseHandler
defaultManager
]
];
return
[
WXApi
handleOpenUniversalLink
:
userActivity
delegate
:
self
];
}
-
(
void
)
scene
:(
UIScene
*
)
scene
continueUserActivity
:(
NSUserActivity
*
)
userActivity
API_AVAILABLE
(
ios
(
13
.
0
)){
[
WXApi
handleOpenUniversalLink
:
userActivity
delegate
:
[
FluwxResponseHandler
defaultManager
]
];
[
WXApi
handleOpenUniversalLink
:
userActivity
delegate
:
self
];
}
-
(
void
)
handleOpenUrlCall
:
(
FlutterMethodCall
*
)
call
...
...
@@ -354,7 +364,7 @@ FlutterMethodChannel *channel = nil;
if
(
handleOpenURLByFluwx
)
{
NSString
*
aURLString
=
[
aNotification
userInfo
][
@"url"
];
NSURL
*
aURL
=
[
NSURL
URLWithString
:
aURLString
];
return
[
WXApi
handleOpenURL
:
aURL
delegate
:
[
FluwxResponseHandler
defaultManager
]
];
return
[
WXApi
handleOpenURL
:
aURL
delegate
:
self
];
}
else
{
return
NO
;
}
...
...
@@ -384,4 +394,247 @@ FlutterMethodChannel *channel = nil;
// }
}
-
(
void
)
onResp
:
(
BaseResp
*
)
resp
{
if
([
resp
isKindOfClass
:[
SendMessageToWXResp
class
]])
{
SendMessageToWXResp
*
messageResp
=
(
SendMessageToWXResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
messageResp
.
description
==
nil
?
@""
:
messageResp
.
description
,
errStr:
messageResp
.
errStr
==
nil
?
@""
:
messageResp
.
errStr
,
errCode:
@
(
messageResp
.
errCode
),
type:
@
(
messageResp
.
type
),
country:
messageResp
.
country
==
nil
?
@""
:
messageResp
.
country
,
lang:
messageResp
.
lang
==
nil
?
@""
:
messageResp
.
lang
};
if
(
channel
!=
nil
){
[
channel
invokeMethod
:
@"onShareResponse"
arguments
:
result
];
}
}
else
if
([
resp
isKindOfClass
:[
SendAuthResp
class
]])
{
SendAuthResp
*
authResp
=
(
SendAuthResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
authResp
.
description
==
nil
?
@""
:
authResp
.
description
,
errStr:
authResp
.
errStr
==
nil
?
@""
:
authResp
.
errStr
,
errCode:
@
(
authResp
.
errCode
),
type:
@
(
authResp
.
type
),
country:
authResp
.
country
==
nil
?
@""
:
authResp
.
country
,
lang:
authResp
.
lang
==
nil
?
@""
:
authResp
.
lang
,
@"code"
:
[
FluwxStringUtil
nilToEmpty
:
authResp
.
code
],
@"state"
:
[
FluwxStringUtil
nilToEmpty
:
authResp
.
state
]
};
if
(
channel
!=
nil
){
[
channel
invokeMethod
:
@"onAuthResponse"
arguments
:
result
];
}
}
else
if
([
resp
isKindOfClass
:[
AddCardToWXCardPackageResp
class
]])
{
}
else
if
([
resp
isKindOfClass
:[
WXChooseCardResp
class
]])
{
}
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
];
}
NSDictionary
*
result
=
@{
description:
chooseInvoiceResp
.
description
==
nil
?
@""
:
chooseInvoiceResp
.
description
,
errStr:
chooseInvoiceResp
.
errStr
==
nil
?
@""
:
chooseInvoiceResp
.
errStr
,
errCode:
@
(
chooseInvoiceResp
.
errCode
),
type:
@
(
chooseInvoiceResp
.
type
),
@"cardItemList"
:
cardItemList
};
if
(
channel
!=
nil
){
[
channel
invokeMethod
:
@"onOpenWechatInvoiceResponse"
arguments
:
result
];
}
}
else
if
([
resp
isKindOfClass
:[
WXSubscribeMsgResp
class
]])
{
WXSubscribeMsgResp
*
subscribeMsgResp
=
(
WXSubscribeMsgResp
*
)
resp
;
NSMutableDictionary
*
result
=
[
NSMutableDictionary
dictionary
];
NSString
*
openid
=
subscribeMsgResp
.
openId
;
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
){
[
channel
invokeMethod
:
@"onSubscribeMsgResp"
arguments
:
result
];
}
}
else
if
([
resp
isKindOfClass
:[
WXLaunchMiniProgramResp
class
]])
{
WXLaunchMiniProgramResp
*
miniProgramResp
=
(
WXLaunchMiniProgramResp
*
)
resp
;
NSDictionary
*
commonResult
=
@{
description:
miniProgramResp
.
description
==
nil
?
@""
:
miniProgramResp
.
description
,
errStr:
miniProgramResp
.
errStr
==
nil
?
@""
:
miniProgramResp
.
errStr
,
errCode:
@
(
miniProgramResp
.
errCode
),
type:
@
(
miniProgramResp
.
type
),
};
NSMutableDictionary
*
result
=
[
NSMutableDictionary
dictionaryWithDictionary
:
commonResult
];
if
(
miniProgramResp
.
extMsg
!=
nil
)
{
result
[
@"extMsg"
]
=
miniProgramResp
.
extMsg
;
}
// @"extMsg":miniProgramResp.extMsg == nil?@"":miniProgramResp.extMsg
if
(
channel
!=
nil
){
[
channel
invokeMethod
:
@"onLaunchMiniProgramResponse"
arguments
:
result
];
}
}
else
if
([
resp
isKindOfClass
:[
WXInvoiceAuthInsertResp
class
]])
{
}
else
if
([
resp
isKindOfClass
:[
WXOpenBusinessWebViewResp
class
]])
{
WXOpenBusinessWebViewResp
*
businessResp
=
(
WXOpenBusinessWebViewResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
[
FluwxStringUtil
nilToEmpty
:
businessResp
.
description
],
errStr:
[
FluwxStringUtil
nilToEmpty
:
resp
.
errStr
],
errCode:
@
(
businessResp
.
errCode
),
type:
@
(
businessResp
.
type
),
@"resultInfo"
:
[
FluwxStringUtil
nilToEmpty
:
businessResp
.
result
],
@"businessType"
:
@
(
businessResp
.
businessType
),
};
if
(
channel
!=
nil
){
[
channel
invokeMethod
:
@"onWXOpenBusinessWebviewResponse"
arguments
:
result
];
}
}
else
if
([
resp
isKindOfClass
:[
WXOpenCustomerServiceResp
class
]])
{
WXOpenCustomerServiceResp
*
customerResp
=
(
WXOpenCustomerServiceResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
[
FluwxStringUtil
nilToEmpty
:
customerResp
.
description
],
errStr:
[
FluwxStringUtil
nilToEmpty
:
resp
.
errStr
],
errCode:
@
(
customerResp
.
errCode
),
type:
@
(
customerResp
.
type
),
@"extMsg"
:
[
FluwxStringUtil
nilToEmpty
:
customerResp
.
extMsg
]
};
if
(
channel
!=
nil
){
[
channel
invokeMethod
:
@"onWXOpenBusinessWebviewResponse"
arguments
:
result
];
}
// 相关错误信息
}
else
if
([
resp
isKindOfClass
:[
WXOpenBusinessViewResp
class
]])
{
WXOpenBusinessViewResp
*
openBusinessViewResp
=
(
WXOpenBusinessViewResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
[
FluwxStringUtil
nilToEmpty
:
openBusinessViewResp
.
description
],
errStr:
[
FluwxStringUtil
nilToEmpty
:
resp
.
errStr
],
errCode:
@
(
openBusinessViewResp
.
errCode
),
@"businessType"
:
openBusinessViewResp
.
businessType
,
type:
@
(
openBusinessViewResp
.
type
),
@"extMsg"
:
[
FluwxStringUtil
nilToEmpty
:
openBusinessViewResp
.
extMsg
]
};
if
(
channel
!=
nil
){
[
channel
invokeMethod
:
@"onOpenBusinessViewResponse"
arguments
:
result
];
}
// 相关错误信息
}
#ifndef NO_PAY
else
if
([
resp
isKindOfClass
:[
WXPayInsuranceResp
class
]])
{
if
([
_delegate
respondsToSelector
:
@selector
(
managerDidRecvPayInsuranceResponse
:)])
{
[
_delegate
managerDidRecvPayInsuranceResponse
:(
WXPayInsuranceResp
*
)
resp
];
}
}
else
if
([
resp
isKindOfClass
:[
PayResp
class
]])
{
PayResp
*
payResp
=
(
PayResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
[
FluwxStringUtil
nilToEmpty
:
payResp
.
description
],
errStr:
[
FluwxStringUtil
nilToEmpty
:
resp
.
errStr
],
errCode:
@
(
payResp
.
errCode
),
type:
@
(
payResp
.
type
),
@"extData"
:
[
FluwxStringUtil
nilToEmpty
:[
FluwxDelegate
defaultManager
].
extData
],
@"returnKey"
:
[
FluwxStringUtil
nilToEmpty
:
payResp
.
returnKey
],
};
[
FluwxDelegate
defaultManager
].
extData
=
nil
;
[
fluwxMethodChannel
invokeMethod
:
@"onPayResponse"
arguments
:
result
];
}
else
if
([
resp
isKindOfClass
:[
WXNontaxPayResp
class
]])
{
}
#endif
}
-
(
void
)
onReq
:
(
BaseReq
*
)
req
{
if
([
req
isKindOfClass
:[
GetMessageFromWXReq
class
]])
{
}
else
if
([
req
isKindOfClass
:[
ShowMessageFromWXReq
class
]])
{
}
else
if
([
req
isKindOfClass
:[
LaunchFromWXReq
class
]])
{
LaunchFromWXReq
*
launchFromWXReq
=
(
LaunchFromWXReq
*
)
req
;
WXMediaMessage
*
wmm
=
launchFromWXReq
.
message
;
NSString
*
msg
=
@""
;
if
(
wmm
==
nil
||
wmm
==
NULL
||
[
wmm
isKindOfClass
:[
NSNull
class
]])
{
msg
=
@""
;
}
else
{
msg
=
wmm
.
messageExt
;
if
(
msg
==
nil
||
msg
==
NULL
||
[
msg
isKindOfClass
:[
NSNull
class
]])
{
msg
=
@""
;
}
}
NSDictionary
*
result
=
@{
@"extMsg"
:
msg
};
if
(
channel
!=
nil
){
[
channel
invokeMethod
:
@"onWXShowMessageFromWX"
arguments
:
result
];
}
}
}
@end
ios/Classes/FluwxResponseHandler.h
deleted
100644 → 0
浏览文件 @
8e878a79
//
// Created by mo on 2020/3/7.
//
#import <Foundation/Foundation.h>
#import <Flutter/Flutter.h>
#import <Flutter/Flutter.h>
#import <WXApi.h>
#import <WXApiObject.h>
@protocol
WXApiManagerDelegate
<
NSObject
>
@optional
-
(
void
)
managerDidRecvGetMessageReq
:
(
GetMessageFromWXReq
*
)
request
;
-
(
void
)
managerDidRecvShowMessageReq
:(
ShowMessageFromWXReq
*
)
request
;
-
(
void
)
managerDidRecvLaunchFromWXReq
:(
LaunchFromWXReq
*
)
request
;
-
(
void
)
managerDidRecvMessageResponse
:(
SendMessageToWXResp
*
)
response
;
-
(
void
)
managerDidRecvAuthResponse
:(
SendAuthResp
*
)
response
;
-
(
void
)
managerDidRecvAddCardResponse
:(
AddCardToWXCardPackageResp
*
)
response
;
-
(
void
)
managerDidRecvChooseCardResponse
:(
WXChooseCardResp
*
)
response
;
-
(
void
)
managerDidRecvChooseInvoiceResponse
:(
WXChooseInvoiceResp
*
)
response
;
-
(
void
)
managerDidRecvSubscribeMsgResponse
:(
WXSubscribeMsgResp
*
)
response
;
-
(
void
)
managerDidRecvLaunchMiniProgram
:(
WXLaunchMiniProgramResp
*
)
response
;
-
(
void
)
managerDidRecvInvoiceAuthInsertResponse
:(
WXInvoiceAuthInsertResp
*
)
response
;
-
(
void
)
managerDidRecvNonTaxpayResponse
:(
WXNontaxPayResp
*
)
response
;
-
(
void
)
managerDidRecvPayInsuranceResponse
:(
WXPayInsuranceResp
*
)
response
;
-
(
void
)
managerDidRecvPaymentResponse
:(
PayResp
*
)
response
;
@end
@interface
FluwxResponseHandler
:
NSObject
<
WXApiDelegate
>
@property
(
nonatomic
,
assign
)
id
<
WXApiManagerDelegate
>
delegate
;
+
(
instancetype
)
defaultManager
;
-
(
void
)
setMethodChannel
:(
FlutterMethodChannel
*
)
flutterMethodChannel
;
@end
ios/Classes/FluwxResponseHandler.m
deleted
100644 → 0
浏览文件 @
8e878a79
//
// Created by mo on 2020/3/7.
//
#import <Flutter/Flutter.h>
#import "FluwxStringUtil.h"
#import <WXApiObject.h>
#import "FluwxResponseHandler.h"
#import "FluwxDelegate.h"
@implementation
FluwxResponseHandler
const
NSString
*
errStr
=
@"errStr"
;
const
NSString
*
errCode
=
@"errCode"
;
const
NSString
*
openId
=
@"openId"
;
const
NSString
*
type
=
@"type"
;
const
NSString
*
lang
=
@"lang"
;
const
NSString
*
country
=
@"country"
;
const
NSString
*
description
=
@"description"
;
#pragma mark - LifeCycle
+
(
instancetype
)
defaultManager
{
static
dispatch_once_t
onceToken
;
static
FluwxResponseHandler
*
instance
;
dispatch_once
(
&
onceToken
,
^
{
instance
=
[[
FluwxResponseHandler
alloc
]
init
];
});
return
instance
;
}
FlutterMethodChannel
*
fluwxMethodChannel
=
nil
;
-
(
void
)
setMethodChannel
:(
FlutterMethodChannel
*
)
flutterMethodChannel
{
fluwxMethodChannel
=
flutterMethodChannel
;
}
-
(
void
)
onNeedGrantReadPasteBoardPermissionWithURL
:(
nonnull
NSURL
*
)
openURL
completion
:(
nonnull
WXGrantReadPasteBoardPermissionCompletion
)
completion
{
/// allow wechat OpenSDK to accessing the clipboard and paste
dispatch_async
(
dispatch_get_main_queue
(),
^
{
completion
();
});
}
#pragma mark - WXApiDelegate
-
(
void
)
onResp
:(
BaseResp
*
)
resp
{
if
([
resp
isKindOfClass
:[
SendMessageToWXResp
class
]])
{
if
(
_delegate
&&
[
_delegate
respondsToSelector
:
@selector
(
managerDidRecvMessageResponse
:)])
{
SendMessageToWXResp
*
messageResp
=
(
SendMessageToWXResp
*
)
resp
;
[
_delegate
managerDidRecvMessageResponse
:
messageResp
];
}
SendMessageToWXResp
*
messageResp
=
(
SendMessageToWXResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
messageResp
.
description
==
nil
?
@""
:
messageResp
.
description
,
errStr:
messageResp
.
errStr
==
nil
?
@""
:
messageResp
.
errStr
,
errCode:
@
(
messageResp
.
errCode
),
type:
@
(
messageResp
.
type
),
country:
messageResp
.
country
==
nil
?
@""
:
messageResp
.
country
,
lang:
messageResp
.
lang
==
nil
?
@""
:
messageResp
.
lang
};
[
fluwxMethodChannel
invokeMethod
:
@"onShareResponse"
arguments
:
result
];
}
else
if
([
resp
isKindOfClass
:[
SendAuthResp
class
]])
{
if
(
_delegate
&&
[
_delegate
respondsToSelector
:
@selector
(
managerDidRecvAuthResponse
:)])
{
SendAuthResp
*
authResp
=
(
SendAuthResp
*
)
resp
;
[
_delegate
managerDidRecvAuthResponse
:
authResp
];
}
SendAuthResp
*
authResp
=
(
SendAuthResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
authResp
.
description
==
nil
?
@""
:
authResp
.
description
,
errStr:
authResp
.
errStr
==
nil
?
@""
:
authResp
.
errStr
,
errCode:
@
(
authResp
.
errCode
),
type:
@
(
authResp
.
type
),
country:
authResp
.
country
==
nil
?
@""
:
authResp
.
country
,
lang:
authResp
.
lang
==
nil
?
@""
:
authResp
.
lang
,
@"code"
:
[
FluwxStringUtil
nilToEmpty
:
authResp
.
code
],
@"state"
:
[
FluwxStringUtil
nilToEmpty
:
authResp
.
state
]
};
[
fluwxMethodChannel
invokeMethod
:
@"onAuthResponse"
arguments
:
result
];
}
else
if
([
resp
isKindOfClass
:[
AddCardToWXCardPackageResp
class
]])
{
if
(
_delegate
&&
[
_delegate
respondsToSelector
:
@selector
(
managerDidRecvAddCardResponse
:)])
{
AddCardToWXCardPackageResp
*
addCardResp
=
(
AddCardToWXCardPackageResp
*
)
resp
;
[
_delegate
managerDidRecvAddCardResponse
:
addCardResp
];
}
}
else
if
([
resp
isKindOfClass
:[
WXChooseCardResp
class
]])
{
if
(
_delegate
&&
[
_delegate
respondsToSelector
:
@selector
(
managerDidRecvChooseCardResponse
:)])
{
WXChooseCardResp
*
chooseCardResp
=
(
WXChooseCardResp
*
)
resp
;
[
_delegate
managerDidRecvChooseCardResponse
:
chooseCardResp
];
}
}
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
];
}
NSDictionary
*
result
=
@{
description:
chooseInvoiceResp
.
description
==
nil
?
@""
:
chooseInvoiceResp
.
description
,
errStr:
chooseInvoiceResp
.
errStr
==
nil
?
@""
:
chooseInvoiceResp
.
errStr
,
errCode:
@
(
chooseInvoiceResp
.
errCode
),
type:
@
(
chooseInvoiceResp
.
type
),
@"cardItemList"
:
cardItemList
};
[
fluwxMethodChannel
invokeMethod
:
@"onOpenWechatInvoiceResponse"
arguments
:
result
];
}
else
if
([
resp
isKindOfClass
:[
WXSubscribeMsgResp
class
]])
{
if
([
_delegate
respondsToSelector
:
@selector
(
managerDidRecvSubscribeMsgResponse
:)])
{
[
_delegate
managerDidRecvSubscribeMsgResponse
:(
WXSubscribeMsgResp
*
)
resp
];
}
WXSubscribeMsgResp
*
subscribeMsgResp
=
(
WXSubscribeMsgResp
*
)
resp
;
NSMutableDictionary
*
result
=
[
NSMutableDictionary
dictionary
];
NSString
*
openid
=
subscribeMsgResp
.
openId
;
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
);
[
fluwxMethodChannel
invokeMethod
:
@"onSubscribeMsgResp"
arguments
:
result
];
}
else
if
([
resp
isKindOfClass
:[
WXLaunchMiniProgramResp
class
]])
{
if
([
_delegate
respondsToSelector
:
@selector
(
managerDidRecvLaunchMiniProgram
:)])
{
[
_delegate
managerDidRecvLaunchMiniProgram
:(
WXLaunchMiniProgramResp
*
)
resp
];
}
WXLaunchMiniProgramResp
*
miniProgramResp
=
(
WXLaunchMiniProgramResp
*
)
resp
;
NSDictionary
*
commonResult
=
@{
description:
miniProgramResp
.
description
==
nil
?
@""
:
miniProgramResp
.
description
,
errStr:
miniProgramResp
.
errStr
==
nil
?
@""
:
miniProgramResp
.
errStr
,
errCode:
@
(
miniProgramResp
.
errCode
),
type:
@
(
miniProgramResp
.
type
),
};
NSMutableDictionary
*
result
=
[
NSMutableDictionary
dictionaryWithDictionary
:
commonResult
];
if
(
miniProgramResp
.
extMsg
!=
nil
)
{
result
[
@"extMsg"
]
=
miniProgramResp
.
extMsg
;
}
// @"extMsg":miniProgramResp.extMsg == nil?@"":miniProgramResp.extMsg
[
fluwxMethodChannel
invokeMethod
:
@"onLaunchMiniProgramResponse"
arguments
:
result
];
}
else
if
([
resp
isKindOfClass
:[
WXInvoiceAuthInsertResp
class
]])
{
if
([
_delegate
respondsToSelector
:
@selector
(
managerDidRecvInvoiceAuthInsertResponse
:)])
{
[
_delegate
managerDidRecvInvoiceAuthInsertResponse
:(
WXInvoiceAuthInsertResp
*
)
resp
];
}
}
else
if
([
resp
isKindOfClass
:[
WXPayInsuranceResp
class
]])
{
if
([
_delegate
respondsToSelector
:
@selector
(
managerDidRecvPayInsuranceResponse
:)])
{
[
_delegate
managerDidRecvPayInsuranceResponse
:(
WXPayInsuranceResp
*
)
resp
];
}
}
else
if
([
resp
isKindOfClass
:[
WXOpenBusinessWebViewResp
class
]])
{
WXOpenBusinessWebViewResp
*
businessResp
=
(
WXOpenBusinessWebViewResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
[
FluwxStringUtil
nilToEmpty
:
businessResp
.
description
],
errStr:
[
FluwxStringUtil
nilToEmpty
:
resp
.
errStr
],
errCode:
@
(
businessResp
.
errCode
),
type:
@
(
businessResp
.
type
),
@"resultInfo"
:
[
FluwxStringUtil
nilToEmpty
:
businessResp
.
result
],
@"businessType"
:
@
(
businessResp
.
businessType
),
};
[
fluwxMethodChannel
invokeMethod
:
@"onWXOpenBusinessWebviewResponse"
arguments
:
result
];
}
else
if
([
resp
isKindOfClass
:[
WXOpenCustomerServiceResp
class
]])
{
WXOpenCustomerServiceResp
*
customerResp
=
(
WXOpenCustomerServiceResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
[
FluwxStringUtil
nilToEmpty
:
customerResp
.
description
],
errStr:
[
FluwxStringUtil
nilToEmpty
:
resp
.
errStr
],
errCode:
@
(
customerResp
.
errCode
),
type:
@
(
customerResp
.
type
),
@"extMsg"
:
[
FluwxStringUtil
nilToEmpty
:
customerResp
.
extMsg
]
};
[
fluwxMethodChannel
invokeMethod
:
@"onWXOpenBusinessWebviewResponse"
arguments
:
result
];
// 相关错误信息
}
else
if
([
resp
isKindOfClass
:[
WXOpenBusinessViewResp
class
]])
{
WXOpenBusinessViewResp
*
openBusinessViewResp
=
(
WXOpenBusinessViewResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
[
FluwxStringUtil
nilToEmpty
:
openBusinessViewResp
.
description
],
errStr:
[
FluwxStringUtil
nilToEmpty
:
resp
.
errStr
],
errCode:
@
(
openBusinessViewResp
.
errCode
),
@"businessType"
:
openBusinessViewResp
.
businessType
,
type:
@
(
openBusinessViewResp
.
type
),
@"extMsg"
:
[
FluwxStringUtil
nilToEmpty
:
openBusinessViewResp
.
extMsg
]
};
[
fluwxMethodChannel
invokeMethod
:
@"onOpenBusinessViewResponse"
arguments
:
result
];
// 相关错误信息
}
#ifndef NO_PAY
else
if
([
resp
isKindOfClass
:[
PayResp
class
]])
{
if
([
_delegate
respondsToSelector
:
@selector
(
managerDidRecvPaymentResponse
:)])
{
[
_delegate
managerDidRecvPaymentResponse
:(
PayResp
*
)
resp
];
}
PayResp
*
payResp
=
(
PayResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
[
FluwxStringUtil
nilToEmpty
:
payResp
.
description
],
errStr:
[
FluwxStringUtil
nilToEmpty
:
resp
.
errStr
],
errCode:
@
(
payResp
.
errCode
),
type:
@
(
payResp
.
type
),
@"extData"
:
[
FluwxStringUtil
nilToEmpty
:[
FluwxDelegate
defaultManager
].
extData
],
@"returnKey"
:
[
FluwxStringUtil
nilToEmpty
:
payResp
.
returnKey
],
};
[
FluwxDelegate
defaultManager
].
extData
=
nil
;
[
fluwxMethodChannel
invokeMethod
:
@"onPayResponse"
arguments
:
result
];
}
else
if
([
resp
isKindOfClass
:[
WXNontaxPayResp
class
]])
{
if
([
_delegate
respondsToSelector
:
@selector
(
managerDidRecvNonTaxpayResponse
:)])
{
[
_delegate
managerDidRecvNonTaxpayResponse
:(
WXNontaxPayResp
*
)
resp
];
}
}
#endif
}
-
(
void
)
onReq
:(
BaseReq
*
)
req
{
if
([
req
isKindOfClass
:[
GetMessageFromWXReq
class
]])
{
if
(
_delegate
&&
[
_delegate
respondsToSelector
:
@selector
(
managerDidRecvGetMessageReq
:)])
{
GetMessageFromWXReq
*
getMessageReq
=
(
GetMessageFromWXReq
*
)
req
;
[
_delegate
managerDidRecvGetMessageReq
:
getMessageReq
];
}
}
else
if
([
req
isKindOfClass
:[
ShowMessageFromWXReq
class
]])
{
if
(
_delegate
&&
[
_delegate
respondsToSelector
:
@selector
(
managerDidRecvShowMessageReq
:)])
{
ShowMessageFromWXReq
*
showMessageReq
=
(
ShowMessageFromWXReq
*
)
req
;
[
_delegate
managerDidRecvShowMessageReq
:
showMessageReq
];
}
}
else
if
([
req
isKindOfClass
:[
LaunchFromWXReq
class
]])
{
if
(
_delegate
&&
[
_delegate
respondsToSelector
:
@selector
(
managerDidRecvLaunchFromWXReq
:)])
{
LaunchFromWXReq
*
launchReq
=
(
LaunchFromWXReq
*
)
req
;
[
_delegate
managerDidRecvLaunchFromWXReq
:
launchReq
];
}
LaunchFromWXReq
*
launchFromWXReq
=
(
LaunchFromWXReq
*
)
req
;
WXMediaMessage
*
wmm
=
launchFromWXReq
.
message
;
NSString
*
msg
=
@""
;
if
(
wmm
==
nil
||
wmm
==
NULL
||
[
wmm
isKindOfClass
:[
NSNull
class
]])
{
msg
=
@""
;
}
else
{
msg
=
wmm
.
messageExt
;
if
(
msg
==
nil
||
msg
==
NULL
||
[
msg
isKindOfClass
:[
NSNull
class
]])
{
msg
=
@""
;
}
}
NSDictionary
*
result
=
@{
@"extMsg"
:
msg
};
[
fluwxMethodChannel
invokeMethod
:
@"onWXShowMessageFromWX"
arguments
:
result
];
}
}
@end
ios/Classes/WXApiRequestHandler.h
浏览文件 @
c40981c1
...
...
@@ -5,7 +5,6 @@
#import <Foundation/Foundation.h>
#import <WXApiObject.h>
#import "FluwxResponseHandler.h"
NS_ASSUME_NONNULL_BEGIN
...
...
@@ -142,6 +141,7 @@ NS_ASSUME_NONNULL_BEGIN
completion
:(
void
(
^
__nullable
)(
BOOL
success
))
completion
;
#ifndef NO_PAY
+
(
void
)
sendPayment
:(
NSString
*
)
appId
PartnerId
:(
NSString
*
)
partnerId
PrepayId
:(
NSString
*
)
prepayId
...
...
@@ -150,6 +150,7 @@ NS_ASSUME_NONNULL_BEGIN
Package
:(
NSString
*
)
package
Sign
:(
NSString
*
)
sign
completion
:(
void
(
^
__nullable
)(
BOOL
success
))
completion
;
#endif
+
(
void
)
openCustomerService
:(
NSString
*
)
url
CorpId
:(
NSString
*
)
corpId
...
...
ios/Classes/WXApiRequestHandler.m
浏览文件 @
c40981c1
...
...
@@ -381,7 +381,7 @@
return
[
WXApi
sendAuthReq
:
req
viewController
:
viewController
delegate:
[
FluwxResponseHandler
defaultManager
]
delegate:
self
completion:
completion
];
}
...
...
@@ -426,7 +426,7 @@
[
WXApi
sendReq
:
chooseInvoiceReq
completion
:
completion
];
}
#ifndef NO_PAY
+
(
void
)
sendPayment
:(
NSString
*
)
appId
PartnerId
:(
NSString
*
)
partnerId
PrepayId
:(
NSString
*
)
prepayId
NonceStr
:(
NSString
*
)
nonceStr
Timestamp
:(
UInt32
)
timestamp
Package
:(
NSString
*
)
package
Sign
:(
NSString
*
)
sign
completion
:(
void
(
^
__nullable
)(
BOOL
success
))
completion
{
...
...
@@ -442,6 +442,7 @@
[
WXApi
sendReq
:
req
completion
:
completion
];
}
#endif
+
(
void
)
openCustomerService
:(
NSString
*
)
url
CorpId
:(
NSString
*
)
corpId
completion
:(
void
(
^
)(
BOOL
))
completion
{
WXOpenCustomerServiceReq
*
req
=
[[
WXOpenCustomerServiceReq
alloc
]
init
];
...
...
ios/fluwx.podspec
浏览文件 @
c40981c1
...
...
@@ -17,16 +17,16 @@ project_dir = calling_dir.slice(0..(calling_dir.index('/.symlinks')))
flutter_project_dir
=
calling_dir
.
slice
(
0
..
(
calling_dir
.
index
(
'/ios/.symlinks'
)))
cfg
=
YAML
.
load_file
(
File
.
join
(
flutter_project_dir
,
'pubspec.yaml'
))
debug_logging
=
'0'
if
cfg
[
'fluwx'
]
&&
cfg
[
'fluwx'
][
'debug_logging'
]
==
'true'
if
cfg
[
'fluwx'
]
&&
cfg
[
'fluwx'
][
'debug_logging'
]
==
true
debug_logging
=
'1'
end
if
cfg
[
'fluwx'
]
&&
cfg
[
'fluwx'
][
'ios'
]
&&
cfg
[
'fluwx'
][
'ios'
][
'no_pay'
]
==
'enabled'
if
cfg
[
'fluwx'
]
&&
cfg
[
'fluwx'
][
'ios'
]
&&
cfg
[
'fluwx'
][
'ios'
][
'no_pay'
]
==
true
fluwx_subspec
=
'no_pay'
else
fluwx_subspec
=
'pay'
end
Pod
::
UI
.
puts
"
wechatsdk
#{
fluwx_subspec
}
"
Pod
::
UI
.
puts
"
using sdk with
#{
fluwx_subspec
}
"
if
cfg
[
'fluwx'
]
&&
(
cfg
[
'fluwx'
][
'app_id'
]
&&
cfg
[
'fluwx'
][
'ios'
]
&&
cfg
[
'fluwx'
][
'ios'
][
'universal_link'
])
app_id
=
cfg
[
'fluwx'
][
'app_id'
]
universal_link
=
cfg
[
'fluwx'
][
'ios'
][
'universal_link'
]
...
...
@@ -57,16 +57,18 @@ The capability of implementing WeChat SDKs in Flutter. With Fluwx, developers ca
sp
.
dependency
'WechatOpenSDK-XCFramework'
,
'~> 2.0.2'
sp
.
pod_target_xcconfig
=
{
'OTHER_LDFLAGS'
=>
'$(inherited) -ObjC -all_load'
,
"GCC_PREPROCESSOR_DEFINITIONS_Debug"
=>
"WECHAT_LOGGING=
#{
debug_logging
}
"
"GCC_PREPROCESSOR_DEFINITIONS_Debug"
=>
"
$(inherited)
WECHAT_LOGGING=
#{
debug_logging
}
"
}
end
s
.
subspec
'no_pay'
do
|
sp
|
sp
.
dependency
'OpenWeChatSDKNoPay'
,
'~> 2.0.2'
sp
.
dependency
'OpenWeChatSDKNoPay'
,
'~> 2.0.2+1'
sp
.
frameworks
=
'CoreGraphics'
,
'Security'
,
'WebKit'
sp
.
libraries
=
'c++'
,
'z'
,
'sqlite3.0'
sp
.
pod_target_xcconfig
=
{
'OTHER_LDFLAGS'
=>
'$(inherited) -ObjC -all_load'
,
'GCC_PREPROCESSOR_DEFINITIONS'
=>
'NO_PAY=1'
,
"GCC_PREPROCESSOR_DEFINITIONS_Debug"
=>
"WECHAT_LOGGING=
#{
debug_logging
}
"
'GCC_PREPROCESSOR_DEFINITIONS'
=>
'
$(inherited)
NO_PAY=1'
,
"GCC_PREPROCESSOR_DEFINITIONS_Debug"
=>
"
$(inherited)
WECHAT_LOGGING=
#{
debug_logging
}
"
}
end
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论