Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
ba1f5abe
提交
ba1f5abe
authored
5月 15, 2023
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
message from wechat
上级
7034b2f6
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
216 行增加
和
88 行删除
+216
-88
FluwxPlugin.kt
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
+20
-0
FluwxRequestHandler.kt
...n/kotlin/com/jarvan/fluwx/handlers/FluwxRequestHandler.kt
+45
-22
FluwxPlugin.m
ios/Classes/FluwxPlugin.m
+102
-62
fluwx.podspec
ios/fluwx.podspec
+1
-1
fluwx.dart
lib/src/fluwx.dart
+6
-0
fluwx_method_channel.dart
lib/src/method_channel/fluwx_method_channel.dart
+6
-3
fluwx_platform_interface.dart
lib/src/method_channel/fluwx_platform_interface.dart
+4
-0
wechat_response.dart
lib/src/response/wechat_response.dart
+26
-0
fluwx_test.dart
test/fluwx_test.dart
+6
-0
没有找到文件。
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
浏览文件 @
ba1f5abe
...
@@ -29,6 +29,8 @@ import io.flutter.plugin.common.MethodChannel
...
@@ -29,6 +29,8 @@ import io.flutter.plugin.common.MethodChannel
import
io.flutter.plugin.common.MethodChannel.MethodCallHandler
import
io.flutter.plugin.common.MethodChannel.MethodCallHandler
import
io.flutter.plugin.common.MethodChannel.Result
import
io.flutter.plugin.common.MethodChannel.Result
import
io.flutter.plugin.common.PluginRegistry
import
io.flutter.plugin.common.PluginRegistry
import
java.util.concurrent.atomic.AtomicBoolean
/** FluwxPlugin */
/** FluwxPlugin */
class
FluwxPlugin
:
FlutterPlugin
,
MethodCallHandler
,
ActivityAware
,
class
FluwxPlugin
:
FlutterPlugin
,
MethodCallHandler
,
ActivityAware
,
...
@@ -47,6 +49,9 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
...
@@ -47,6 +49,9 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
private
var
fluwxChannel
:
MethodChannel
?
=
null
private
var
fluwxChannel
:
MethodChannel
?
=
null
private
var
context
:
Context
?
=
null
private
var
context
:
Context
?
=
null
private
val
attemptToResumeMsgFromWxFlag
=
AtomicBoolean
(
false
)
private
var
activityPluginBinding
:
ActivityPluginBinding
?
=
null
private
fun
handelIntent
(
intent
:
Intent
)
{
private
fun
handelIntent
(
intent
:
Intent
)
{
intent
.
getStringExtra
(
KEY_FLUWX_REQUEST_INFO_EXT_MSG
)
?.
let
{
intent
.
getStringExtra
(
KEY_FLUWX_REQUEST_INFO_EXT_MSG
)
?.
let
{
...
@@ -96,10 +101,22 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
...
@@ -96,10 +101,22 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
call
.
method
==
"openWeChatInvoice"
->
openWeChatInvoice
(
call
,
result
)
call
.
method
==
"openWeChatInvoice"
->
openWeChatInvoice
(
call
,
result
)
call
.
method
==
"openUrl"
->
openUrl
(
call
,
result
)
call
.
method
==
"openUrl"
->
openUrl
(
call
,
result
)
call
.
method
==
"openRankList"
->
openRankList
(
result
)
call
.
method
==
"openRankList"
->
openRankList
(
result
)
call
.
method
==
"attemptToResumeMsgFromWx"
->
attemptToResumeMsgFromWx
(
result
)
else
->
result
.
notImplemented
()
else
->
result
.
notImplemented
()
}
}
}
}
private
fun
attemptToResumeMsgFromWx
(
result
:
Result
)
{
if
(
attemptToResumeMsgFromWxFlag
.
compareAndSet
(
false
,
true
))
{
activityPluginBinding
?.
activity
?.
intent
?.
let
{
FluwxRequestHandler
.
handleRequestInfoFromIntent
(
it
)
}
result
.
success
(
null
)
}
else
{
result
.
error
(
"attemptToResumeMsgFromWx error"
,
null
,
null
)
}
}
private
fun
openWeChatInvoice
(
call
:
MethodCall
,
result
:
Result
)
{
private
fun
openWeChatInvoice
(
call
:
MethodCall
,
result
:
Result
)
{
if
(
WXAPiHandler
.
wxApi
==
null
)
{
if
(
WXAPiHandler
.
wxApi
==
null
)
{
result
.
error
(
"Unassigned WxApi"
,
"please config wxapi first"
,
null
)
result
.
error
(
"Unassigned WxApi"
,
"please config wxapi first"
,
null
)
...
@@ -127,6 +144,7 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
...
@@ -127,6 +144,7 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
override
fun
onDetachedFromEngine
(
@NonNull
binding
:
FlutterPlugin
.
FlutterPluginBinding
)
{
override
fun
onDetachedFromEngine
(
@NonNull
binding
:
FlutterPlugin
.
FlutterPluginBinding
)
{
shareHandler
?.
onDestroy
()
shareHandler
?.
onDestroy
()
authHandler
?.
removeAllListeners
()
authHandler
?.
removeAllListeners
()
activityPluginBinding
=
null
}
}
override
fun
onDetachedFromActivity
()
{
override
fun
onDetachedFromActivity
()
{
...
@@ -141,6 +159,7 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
...
@@ -141,6 +159,7 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
override
fun
onAttachedToActivity
(
binding
:
ActivityPluginBinding
)
{
override
fun
onAttachedToActivity
(
binding
:
ActivityPluginBinding
)
{
// WXAPiHandler.setContext(binding.activity.applicationContext)
// WXAPiHandler.setContext(binding.activity.applicationContext)
activityPluginBinding
=
binding
handelIntent
(
binding
.
activity
.
intent
)
handelIntent
(
binding
.
activity
.
intent
)
FluwxRequestHandler
.
handleRequestInfoFromIntent
(
binding
.
activity
.
intent
)
FluwxRequestHandler
.
handleRequestInfoFromIntent
(
binding
.
activity
.
intent
)
shareHandler
?.
permissionHandler
=
PermissionHandler
(
binding
.
activity
)
shareHandler
?.
permissionHandler
=
PermissionHandler
(
binding
.
activity
)
...
@@ -287,6 +306,7 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
...
@@ -287,6 +306,7 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
result
.
success
(
false
)
result
.
success
(
false
)
}
}
}
}
private
fun
openRankList
(
result
:
Result
)
{
private
fun
openRankList
(
result
:
Result
)
{
val
req
=
OpenRankList
.
Req
()
val
req
=
OpenRankList
.
Req
()
WXAPiHandler
.
wxApi
?.
sendReq
(
req
,
SendReqCallback
{
WXAPiHandler
.
wxApi
?.
sendReq
(
req
,
SendReqCallback
{
...
...
android/src/main/kotlin/com/jarvan/fluwx/handlers/FluwxRequestHandler.kt
浏览文件 @
ba1f5abe
...
@@ -29,6 +29,7 @@ import com.jarvan.fluwx.utils.KEY_FLUWX_REQUEST_INFO_BUNDLE
...
@@ -29,6 +29,7 @@ import com.jarvan.fluwx.utils.KEY_FLUWX_REQUEST_INFO_BUNDLE
import
com.jarvan.fluwx.utils.KEY_FLUWX_REQUEST_INFO_EXT_MSG
import
com.jarvan.fluwx.utils.KEY_FLUWX_REQUEST_INFO_EXT_MSG
import
com.jarvan.fluwx.utils.startFlutterActivity
import
com.jarvan.fluwx.utils.startFlutterActivity
import
com.tencent.mm.opensdk.modelbase.BaseReq
import
com.tencent.mm.opensdk.modelbase.BaseReq
import
com.tencent.mm.opensdk.modelmsg.LaunchFromWX
import
com.tencent.mm.opensdk.modelmsg.ShowMessageFromWX
import
com.tencent.mm.opensdk.modelmsg.ShowMessageFromWX
import
java.security.cert.Extension
import
java.security.cert.Extension
...
@@ -42,6 +43,8 @@ object FluwxRequestHandler {
...
@@ -42,6 +43,8 @@ object FluwxRequestHandler {
val
type
=
getInt
(
"_wxapi_command_type"
,
-
9999
)
val
type
=
getInt
(
"_wxapi_command_type"
,
-
9999
)
if
(
type
==
4
)
{
if
(
type
==
4
)
{
handleShowMessageFromWXBundle
(
this
)
handleShowMessageFromWXBundle
(
this
)
}
else
if
(
type
==
6
)
{
handleWXLaunchFromWXBundle
(
this
)
}
}
}
}
}
}
...
@@ -49,45 +52,65 @@ object FluwxRequestHandler {
...
@@ -49,45 +52,65 @@ object FluwxRequestHandler {
private
fun
handleShowMessageFromWXBundle
(
bundle
:
Bundle
)
=
private
fun
handleShowMessageFromWXBundle
(
bundle
:
Bundle
)
=
handleWXShowMessageFromWX
(
ShowMessageFromWX
.
Req
(
bundle
))
handleWXShowMessageFromWX
(
ShowMessageFromWX
.
Req
(
bundle
))
private
fun
handleWXLaunchFromWXBundle
(
bundle
:
Bundle
)
=
handleWXLaunchFromWX
(
LaunchFromWX
.
Req
(
bundle
))
private
fun
handleRequest
(
req
:
BaseReq
)
{
private
fun
handleRequest
(
req
:
BaseReq
)
{
when
(
req
)
{
when
(
req
)
{
is
ShowMessageFromWX
.
Req
->
handleWXShowMessageFromWX
(
req
)
is
ShowMessageFromWX
.
Req
->
handleWXShowMessageFromWX
(
req
)
is
LaunchFromWX
.
Req
->
handleWXLaunchFromWX
(
req
)
}
}
}
}
private
fun
handleWXShowMessageFromWX
(
req
:
ShowMessageFromWX
.
Req
)
{
private
fun
handleWXShowMessageFromWX
(
req
:
ShowMessageFromWX
.
Req
)
{
val
result
=
mapOf
(
val
result
=
mapOf
(
"extMsg"
to
req
.
message
.
messageExt
"extMsg"
to
req
.
message
.
messageExt
,
"messageAction"
to
req
.
message
.
messageAction
,
"description"
to
req
.
message
.
description
,
"lang"
to
req
.
lang
,
"description"
to
req
.
country
,
)
)
FluwxPlugin
.
extMsg
=
req
.
message
.
messageExt
;
FluwxPlugin
.
extMsg
=
req
.
message
.
messageExt
FluwxPlugin
.
callingChannel
?.
invokeMethod
(
"onWXShowMessageFromWX"
,
result
)
FluwxPlugin
.
callingChannel
?.
invokeMethod
(
"onWXShowMessageFromWX"
,
result
)
}
}
private
fun
handleWXLaunchFromWX
(
req
:
LaunchFromWX
.
Req
)
{
val
result
=
mapOf
(
"extMsg"
to
req
.
messageExt
,
"messageAction"
to
req
.
messageAction
,
"lang"
to
req
.
lang
,
"country"
to
req
.
country
,
)
FluwxPlugin
.
callingChannel
?.
invokeMethod
(
"onWXLaunchFromWX"
,
result
)
}
private
fun
defaultOnReqDelegate
(
baseReq
:
BaseReq
,
activity
:
Activity
)
{
private
fun
defaultOnReqDelegate
(
baseReq
:
BaseReq
,
activity
:
Activity
)
{
// FIXME: 可能是官方的Bug,从微信拉起APP的Intent类型不对,无法跳转回Flutter Activity
// FIXME: 可能是官方的Bug,从微信拉起APP的Intent类型不对,无法跳转回Flutter Activity
// 稳定复现场景:微信版本为7.0.5,小程序SDK为2.7.7
// 稳定复现场景:微信版本为7.0.5,小程序SDK为2.7.7
if
(
baseReq
.
type
==
4
)
{
// com.tencent.mm.opensdk.constants.ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX = 4
// com.tencent.mm.opensdk.constants.ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX = 4
if
(!
WXAPiHandler
.
coolBoot
)
{
if
(!
WXAPiHandler
.
coolBoot
)
{
handleRequest
(
baseReq
)
handleRequest
(
baseReq
)
activity
.
startFlutterActivity
()
activity
.
startFlutterActivity
()
}
else
{
}
else
{
when
(
baseReq
)
{
when
(
baseReq
)
{
is
ShowMessageFromWX
.
Req
->
{
is
ShowMessageFromWX
.
Req
->
{
activity
.
startFlutterActivity
(
activity
.
startFlutterActivity
(
wxRequestBundle
=
Bundle
().
apply
{
wxRequestBundle
=
Bundle
().
apply
{
baseReq
.
toBundle
(
this
)
baseReq
.
toBundle
(
this
)
},
},
bundle
=
Bundle
().
apply
{
bundle
=
Bundle
().
apply
{
putString
(
putString
(
KEY_FLUWX_REQUEST_INFO_EXT_MSG
,
KEY_FLUWX_REQUEST_INFO_EXT_MSG
,
baseReq
.
message
.
messageExt
baseReq
.
message
.
messageExt
)
)
})
})
WXAPiHandler
.
coolBoot
=
false
WXAPiHandler
.
coolBoot
=
false
}
}
}
}
}
}
}
}
}
...
...
ios/Classes/FluwxPlugin.m
浏览文件 @
ba1f5abe
...
@@ -42,7 +42,13 @@ NSUInteger defaultThumbnailSize = 32 * 1024;
...
@@ -42,7 +42,13 @@ NSUInteger defaultThumbnailSize = 32 * 1024;
typedef
void
(
^
FluwxWXReqRunnable
)(
void
);
typedef
void
(
^
FluwxWXReqRunnable
)(
void
);
@implementation
FluwxPlugin
@implementation
FluwxPlugin
{
FlutterMethodChannel
*
_channel
;
WechatAuthSDK
*
_qrauth
;
BOOL
_isRunning
;
BOOL
_attemptToResumeMsgFromWxFlag
;
FluwxWXReqRunnable
_attemptToResumeMsgFromWxRunnable
;
}
const
NSString
*
errStr
=
@"errStr"
;
const
NSString
*
errStr
=
@"errStr"
;
const
NSString
*
errCode
=
@"errCode"
;
const
NSString
*
errCode
=
@"errCode"
;
...
@@ -53,35 +59,14 @@ const NSString *country = @"country";
...
@@ -53,35 +59,14 @@ const NSString *country = @"country";
const
NSString
*
description
=
@"description"
;
const
NSString
*
description
=
@"description"
;
BOOL
_isRunning
;
FluwxWXReqRunnable
_initialWXReqRunnable
;
FluwxWXReqRunnable
_initialWXReqRunnable
;
BOOL
handleOpenURLByFluwx
=
YES
;
BOOL
handleOpenURLByFluwx
=
YES
;
FlutterMethodChannel
*
channel
=
nil
;
WechatAuthSDK
*
_qrauth
;
NSObject
<
FlutterPluginRegistrar
>
*
_fluwxRegistrar
;
NSObject
<
FlutterPluginRegistrar
>
*
_fluwxRegistrar
;
+
(
void
)
registerWithRegistrar
:(
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
{
#if TARGET_OS_IPHONE
if
(
channel
==
nil
)
{
#endif
channel
=
[
FlutterMethodChannel
methodChannelWithName
:
@"com.jarvanmo/fluwx"
binaryMessenger
:[
registrar
messenger
]];
FluwxPlugin
*
instance
=
[[
FluwxPlugin
alloc
]
initWithRegistrar
:
registrar
methodChannel
:
channel
];
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
[
registrar
addApplicationDelegate
:
instance
];
#if TARGET_OS_IPHONE
}
#endif
}
-
(
instancetype
)
initWithRegistrar
:(
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
methodChannel
:(
FlutterMethodChannel
*
)
flutterMethodChannel
{
-
(
instancetype
)
initWithRegistrar
:(
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
methodChannel
:(
FlutterMethodChannel
*
)
flutterMethodChannel
{
self
=
[
super
init
];
self
=
[
super
init
];
if
(
self
)
{
if
(
self
)
{
...
@@ -90,8 +75,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -90,8 +75,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
_qrauth
=
[[
WechatAuthSDK
alloc
]
init
];
_qrauth
=
[[
WechatAuthSDK
alloc
]
init
];
_qrauth
.
delegate
=
self
;
_qrauth
.
delegate
=
self
;
thumbnailWidth
=
150
;
thumbnailWidth
=
150
;
channel
=
flutterMethodChannel
;
_
channel
=
flutterMethodChannel
;
_attemptToResumeMsgFromWxFlag
=
false
;
#if WECHAT_LOGGING
#if WECHAT_LOGGING
[
WXApi
startLogByLevel
:
WXLogLevelDetail
logBlock
:
^
(
NSString
*
log
)
{
[
WXApi
startLogByLevel
:
WXLogLevelDetail
logBlock
:
^
(
NSString
*
log
)
{
[
self
logToFlutterWithDetail
:
log
];
[
self
logToFlutterWithDetail
:
log
];
...
@@ -142,6 +127,17 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -142,6 +127,17 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
[
self
handleOpenUrlCall
:
call
result
:
result
];
[
self
handleOpenUrlCall
:
call
result
:
result
];
}
else
if
([
@"openWeChatInvoice"
isEqualToString
:
call
.
method
])
{
}
else
if
([
@"openWeChatInvoice"
isEqualToString
:
call
.
method
])
{
[
self
openWeChatInvoice
:
call
result
:
result
];
[
self
openWeChatInvoice
:
call
result
:
result
];
}
else
if
([
@""
isEqualToString
:
call
.
method
]){
if
(
!
_attemptToResumeMsgFromWxFlag
)
{
_attemptToResumeMsgFromWxFlag
=
YES
;
if
(
_attemptToResumeMsgFromWxRunnable
!=
nil
)
{
_attemptToResumeMsgFromWxRunnable
();
_attemptToResumeMsgFromWxRunnable
=
nil
;
}
result
(
nil
);
}
else
{
result
([
FlutterError
errorWithCode
:
@"attemptToResumeMsgFromWx error"
message
:
nil
details
:
nil
]);
}
}
}
else
if
([
@"payWithFluwx"
isEqualToString
:
call
.
method
])
{
else
if
([
@"payWithFluwx"
isEqualToString
:
call
.
method
])
{
#ifndef NO_PAY
#ifndef NO_PAY
...
@@ -161,6 +157,16 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -161,6 +157,16 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
}
}
}
}
+
(
void
)
registerWithRegistrar
:(
nonnull
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
{
<
#
code
#
>
}
+
(
void
)
registerWithRegistrar
:(
nonnull
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
{
<
#
code
#
>
}
-
(
void
)
openWeChatInvoice
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
-
(
void
)
openWeChatInvoice
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
NSString
*
appId
=
call
.
arguments
[
@"appId"
];
NSString
*
appId
=
call
.
arguments
[
@"appId"
];
...
@@ -314,12 +320,16 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -314,12 +320,16 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
-
(
void
)
handleSubscribeWithCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
-
(
void
)
handleSubscribeWithCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
NSDictionary
*
params
=
call
.
arguments
;
NSDictionary
*
params
=
call
.
arguments
;
NSString
*
appId
=
[
params
valueForKey
:
@"appId"
];
NSString
*
appId
=
[
params
valueForKey
:
@"appId"
];
int
scene
=
[[
params
valueForKey
:
@"scene"
]
intValue
];
NSNumber
*
scene
=
[
params
valueForKey
:
@"scene"
];
NSString
*
templateId
=
[
params
valueForKey
:
@"templateId"
];
NSString
*
templateId
=
[
params
valueForKey
:
@"templateId"
];
NSString
*
reserved
=
[
params
valueForKey
:
@"reserved"
];
NSString
*
reserved
=
[
params
valueForKey
:
@"reserved"
];
WXSubscribeMsgReq
*
req
=
[
WXSubscribeMsgReq
new
];
WXSubscribeMsgReq
*
req
=
[
WXSubscribeMsgReq
new
];
req
.
scene
=
(
UInt32
)
scene
;
#if __LP64__
req
.
scene
=
[
scene
unsignedIntValue
];
#else
req
.
scene
=
[
scene
unsignedLongValue
];
#endif
req
.
templateId
=
templateId
;
req
.
templateId
=
templateId
;
req
.
reserved
=
reserved
;
req
.
reserved
=
reserved
;
req
.
openID
=
appId
;
req
.
openID
=
appId
;
...
@@ -419,11 +429,11 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -419,11 +429,11 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
}
}
-
(
void
)
logToFlutterWithDetail
:
(
NSString
*
)
detail
{
-
(
void
)
logToFlutterWithDetail
:
(
NSString
*
)
detail
{
if
(
channel
!=
nil
){
if
(
_
channel
!=
nil
){
NSDictionary
*
result
=
@{
NSDictionary
*
result
=
@{
@"detail"
:
detail
@"detail"
:
detail
};
};
[
channel
invokeMethod
:
@"wechatLog"
arguments
:
result
];
[
_
channel
invokeMethod
:
@"wechatLog"
arguments
:
result
];
}
}
}
}
...
@@ -805,8 +815,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -805,8 +815,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
type:
@
(
messageResp
.
type
),
type:
@
(
messageResp
.
type
),
country:
messageResp
.
country
==
nil
?
@""
:
messageResp
.
country
,
country:
messageResp
.
country
==
nil
?
@""
:
messageResp
.
country
,
lang:
messageResp
.
lang
==
nil
?
@""
:
messageResp
.
lang
};
lang:
messageResp
.
lang
==
nil
?
@""
:
messageResp
.
lang
};
if
(
channel
!=
nil
){
if
(
_
channel
!=
nil
){
[
channel
invokeMethod
:
@"onShareResponse"
arguments
:
result
];
[
_
channel
invokeMethod
:
@"onShareResponse"
arguments
:
result
];
}
}
...
@@ -825,8 +835,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -825,8 +835,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
};
};
if
(
channel
!=
nil
){
if
(
_
channel
!=
nil
){
[
channel
invokeMethod
:
@"onAuthResponse"
arguments
:
result
];
[
_
channel
invokeMethod
:
@"onAuthResponse"
arguments
:
result
];
}
}
}
else
if
([
resp
isKindOfClass
:[
AddCardToWXCardPackageResp
class
]])
{
}
else
if
([
resp
isKindOfClass
:[
AddCardToWXCardPackageResp
class
]])
{
...
@@ -870,9 +880,9 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -870,9 +880,9 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
@"cardItemList"
:
cardItemList
@"cardItemList"
:
cardItemList
};
};
if
(
channel
!=
nil
){
if
(
_
channel
!=
nil
){
[
channel
invokeMethod
:
@"onOpenWechatInvoiceResponse"
arguments
:
result
];
[
_
channel
invokeMethod
:
@"onOpenWechatInvoiceResponse"
arguments
:
result
];
}
}
}
else
if
([
resp
isKindOfClass
:[
WXSubscribeMsgResp
class
]])
{
}
else
if
([
resp
isKindOfClass
:[
WXSubscribeMsgResp
class
]])
{
...
@@ -901,8 +911,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -901,8 +911,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
UInt32
scene
=
subscribeMsgResp
.
scene
;
UInt32
scene
=
subscribeMsgResp
.
scene
;
result
[
@"scene"
]
=
@
(
scene
);
result
[
@"scene"
]
=
@
(
scene
);
if
(
channel
!=
nil
){
if
(
_
channel
!=
nil
){
[
channel
invokeMethod
:
@"onSubscribeMsgResp"
arguments
:
result
];
[
_
channel
invokeMethod
:
@"onSubscribeMsgResp"
arguments
:
result
];
}
}
}
else
if
([
resp
isKindOfClass
:[
WXLaunchMiniProgramResp
class
]])
{
}
else
if
([
resp
isKindOfClass
:[
WXLaunchMiniProgramResp
class
]])
{
...
@@ -925,8 +935,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -925,8 +935,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
// @"extMsg":miniProgramResp.extMsg == nil?@"":miniProgramResp.extMsg
// @"extMsg":miniProgramResp.extMsg == nil?@"":miniProgramResp.extMsg
if
(
channel
!=
nil
){
if
(
_
channel
!=
nil
){
[
channel
invokeMethod
:
@"onLaunchMiniProgramResponse"
arguments
:
result
];
[
_
channel
invokeMethod
:
@"onLaunchMiniProgramResponse"
arguments
:
result
];
}
}
...
@@ -943,8 +953,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -943,8 +953,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
@"resultInfo"
:
[
FluwxStringUtil
nilToEmpty
:
businessResp
.
result
],
@"resultInfo"
:
[
FluwxStringUtil
nilToEmpty
:
businessResp
.
result
],
@"businessType"
:
@
(
businessResp
.
businessType
),
@"businessType"
:
@
(
businessResp
.
businessType
),
};
};
if
(
channel
!=
nil
){
if
(
_
channel
!=
nil
){
[
channel
invokeMethod
:
@"onWXOpenBusinessWebviewResponse"
arguments
:
result
];
[
_
channel
invokeMethod
:
@"onWXOpenBusinessWebviewResponse"
arguments
:
result
];
}
}
}
else
if
([
resp
isKindOfClass
:[
WXOpenCustomerServiceResp
class
]])
}
else
if
([
resp
isKindOfClass
:[
WXOpenCustomerServiceResp
class
]])
...
@@ -958,8 +968,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -958,8 +968,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
type:
@
(
customerResp
.
type
),
type:
@
(
customerResp
.
type
),
@"extMsg"
:
[
FluwxStringUtil
nilToEmpty
:
customerResp
.
extMsg
]
@"extMsg"
:
[
FluwxStringUtil
nilToEmpty
:
customerResp
.
extMsg
]
};
};
if
(
channel
!=
nil
){
if
(
_
channel
!=
nil
){
[
channel
invokeMethod
:
@"onWXOpenBusinessWebviewResponse"
arguments
:
result
];
[
_
channel
invokeMethod
:
@"onWXOpenBusinessWebviewResponse"
arguments
:
result
];
}
}
// 相关错误信息
// 相关错误信息
...
@@ -975,8 +985,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -975,8 +985,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
type:
@
(
openBusinessViewResp
.
type
),
type:
@
(
openBusinessViewResp
.
type
),
@"extMsg"
:
[
FluwxStringUtil
nilToEmpty
:
openBusinessViewResp
.
extMsg
]
@"extMsg"
:
[
FluwxStringUtil
nilToEmpty
:
openBusinessViewResp
.
extMsg
]
};
};
if
(
channel
!=
nil
){
if
(
_
channel
!=
nil
){
[
channel
invokeMethod
:
@"onOpenBusinessViewResponse"
arguments
:
result
];
[
_
channel
invokeMethod
:
@"onOpenBusinessViewResponse"
arguments
:
result
];
}
}
// 相关错误信息
// 相关错误信息
...
@@ -997,8 +1007,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -997,8 +1007,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
@"returnKey"
:
[
FluwxStringUtil
nilToEmpty
:
payResp
.
returnKey
],
@"returnKey"
:
[
FluwxStringUtil
nilToEmpty
:
payResp
.
returnKey
],
};
};
[
FluwxDelegate
defaultManager
].
extData
=
nil
;
[
FluwxDelegate
defaultManager
].
extData
=
nil
;
if
(
channel
!=
nil
){
if
(
_
channel
!=
nil
){
[
channel
invokeMethod
:
@"onPayResponse"
arguments
:
result
];
[
_
channel
invokeMethod
:
@"onPayResponse"
arguments
:
result
];
}
}
}
else
if
([
resp
isKindOfClass
:[
WXNontaxPayResp
class
]])
{
}
else
if
([
resp
isKindOfClass
:[
WXNontaxPayResp
class
]])
{
...
@@ -1010,24 +1020,54 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -1010,24 +1020,54 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
if
([
req
isKindOfClass
:[
GetMessageFromWXReq
class
]])
{
if
([
req
isKindOfClass
:[
GetMessageFromWXReq
class
]])
{
}
else
if
([
req
isKindOfClass
:[
ShowMessageFromWXReq
class
]])
{
}
else
if
([
req
isKindOfClass
:[
ShowMessageFromWXReq
class
]])
{
//onWXLaunchFromWX
ShowMessageFromWXReq
*
showMessageFromWXReq
=
(
ShowMessageFromWXReq
*
)
req
;
WXMediaMessage
*
wmm
=
showMessageFromWXReq
.
message
;
NSDictionary
*
result
=
@{
@"extMsg"
:
wmm
.
messageExt
,
@"messageAction"
:
wmm
.
messageAction
,
@"lang"
:
showMessageFromWXReq
.
lang
,
@"country"
:
showMessageFromWXReq
.
country
,
};
[
FluwxDelegate
defaultManager
].
extMsg
=
wmm
.
messageExt
;
if
(
_isRunning
)
{
[
_channel
invokeMethod
:
@"onWXShowMessageFromWX"
arguments
:
result
];
}
else
{
__weak
typeof
(
self
)
weakSelf
=
self
;
_initialWXReqRunnable
=
^
()
{
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
strongSelf
->
_channel
invokeMethod
:
@"onWXShowMessageFromWX"
arguments
:
result
];
};
}
}
else
if
([
req
isKindOfClass
:[
LaunchFromWXReq
class
]])
{
}
else
if
([
req
isKindOfClass
:[
LaunchFromWXReq
class
]])
{
LaunchFromWXReq
*
launchFromWXReq
=
(
LaunchFromWXReq
*
)
req
;
LaunchFromWXReq
*
launchFromWXReq
=
(
LaunchFromWXReq
*
)
req
;
WXMediaMessage
*
wmm
=
launchFromWXReq
.
message
;
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
=
@{
NSDictionary
*
result
=
@{
@"extMsg"
:
msg
@"extMsg"
:
wmm
.
messageExt
,
@"messageAction"
:
wmm
.
messageAction
,
@"lang"
:
launchFromWXReq
.
lang
,
@"country"
:
launchFromWXReq
.
country
,
};
};
[
FluwxDelegate
defaultManager
].
extMsg
=
wmm
.
messageExt
;
if
(
_isRunning
)
{
[
_channel
invokeMethod
:
@"onWXLaunchFromWX"
arguments
:
result
];
}
else
{
__weak
typeof
(
self
)
weakSelf
=
self
;
_initialWXReqRunnable
=
^
()
{
__strong
typeof
(
weakSelf
)
strongSelf
=
weakSelf
;
[
strongSelf
->
_channel
invokeMethod
:
@"onWXLaunchFromWX"
arguments
:
result
];
};
}
if
(
channel
!=
nil
){
if
(
channel
!=
nil
){
[
channel
invokeMethod
:
@"onWXShowMessageFromWX"
arguments
:
result
];
[
channel
invokeMethod
:
@"onWXShowMessageFromWX"
arguments
:
result
];
}
}
...
@@ -1462,8 +1502,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -1462,8 +1502,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
}
}
-
(
void
)
onQrcodeScanned
{
-
(
void
)
onQrcodeScanned
{
if
(
channel
!=
nil
){
if
(
_
channel
!=
nil
){
[
channel
invokeMethod
:
@"onQRCodeScanned"
arguments
:@{
@"errCode"
:
@0
}];
[
_
channel
invokeMethod
:
@"onQRCodeScanned"
arguments
:@{
@"errCode"
:
@0
}];
}
}
}
}
...
@@ -1472,8 +1512,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -1472,8 +1512,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
// if (imageData == nil) {
// if (imageData == nil) {
// imageData = UIImageJPEGRepresentation(image, 1);
// imageData = UIImageJPEGRepresentation(image, 1);
// }
// }
if
(
channel
!=
nil
){
if
(
_
channel
!=
nil
){
[
channel
invokeMethod
:
@"onAuthGotQRCode"
arguments
:@{
@"errCode"
:
@0
,
@"qrCode"
:
imageData
}];
[
_
channel
invokeMethod
:
@"onAuthGotQRCode"
arguments
:@{
@"errCode"
:
@0
,
@"qrCode"
:
imageData
}];
}
}
}
}
...
@@ -1483,8 +1523,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
...
@@ -1483,8 +1523,8 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
if
(
authCode
!=
nil
)
{
if
(
authCode
!=
nil
)
{
result
[
@"authCode"
]
=
authCode
;
result
[
@"authCode"
]
=
authCode
;
}
}
if
(
channel
!=
nil
){
if
(
_
channel
!=
nil
){
[
channel
invokeMethod
:
@"onAuthByQRCodeFinished"
arguments
:
result
];
[
_
channel
invokeMethod
:
@"onAuthByQRCodeFinished"
arguments
:
result
];
}
}
}
}
...
...
ios/fluwx.podspec
浏览文件 @
ba1f5abe
...
@@ -69,7 +69,7 @@ The capability of implementing WeChat SDKs in Flutter. With Fluwx, developers ca
...
@@ -69,7 +69,7 @@ The capability of implementing WeChat SDKs in Flutter. With Fluwx, developers ca
end
end
s
.
subspec
'no_pay'
do
|
sp
|
s
.
subspec
'no_pay'
do
|
sp
|
sp
.
dependency
'OpenWeChatSDKNoPay'
,
'~> 2.0.2+
1
'
sp
.
dependency
'OpenWeChatSDKNoPay'
,
'~> 2.0.2+
2
'
sp
.
frameworks
=
'CoreGraphics'
,
'Security'
,
'WebKit'
sp
.
frameworks
=
'CoreGraphics'
,
'Security'
,
'WebKit'
sp
.
libraries
=
'c++'
,
'z'
,
'sqlite3.0'
sp
.
libraries
=
'c++'
,
'z'
,
'sqlite3.0'
if
debug_logging
if
debug_logging
...
...
lib/src/fluwx.dart
浏览文件 @
ba1f5abe
...
@@ -94,6 +94,12 @@ class Fluwx {
...
@@ -94,6 +94,12 @@ class Fluwx {
return
FluwxPlatform
.
instance
.
pay
(
which
);
return
FluwxPlatform
.
instance
.
pay
(
which
);
}
}
/// Try to reload data from cold boot. For example, the app is launched by mini program and
/// we can get ext message by calling this.
Future
<
void
>
attemptToResumeMsgFromWx
()
async
{
return
FluwxPlatform
.
instance
.
attemptToResumeMsgFromWx
();
}
/// Subscribe responses from WeChat
/// Subscribe responses from WeChat
subscribeResponse
(
Function
(
WeChatResponse
response
)
listener
)
{
subscribeResponse
(
Function
(
WeChatResponse
response
)
listener
)
{
_responseListeners
.
add
(
listener
);
_responseListeners
.
add
(
listener
);
...
...
lib/src/method_channel/fluwx_method_channel.dart
浏览文件 @
ba1f5abe
...
@@ -183,9 +183,7 @@ class MethodChannelFluwx extends FluwxPlatform {
...
@@ -183,9 +183,7 @@ class MethodChannelFluwx extends FluwxPlatform {
switch
(
which
)
{
switch
(
which
)
{
case
Payment
():
case
Payment
():
return
await
methodChannel
.
invokeMethod
(
return
await
methodChannel
.
invokeMethod
(
'payWithFluwx'
,
'payWithFluwx'
,
which
.
arguments
);
which
.
arguments
);
case
HongKongWallet
():
case
HongKongWallet
():
return
await
methodChannel
.
invokeMethod
(
return
await
methodChannel
.
invokeMethod
(
'payWithHongKongWallet'
,
which
.
arguments
);
'payWithHongKongWallet'
,
which
.
arguments
);
...
@@ -205,6 +203,11 @@ class MethodChannelFluwx extends FluwxPlatform {
...
@@ -205,6 +203,11 @@ class MethodChannelFluwx extends FluwxPlatform {
return
await
methodChannel
.
invokeMethod
(
'stopAuthByQRCode'
);
return
await
methodChannel
.
invokeMethod
(
'stopAuthByQRCode'
);
}
}
@override
Future
<
void
>
attemptToResumeMsgFromWx
()
async
{
return
await
methodChannel
.
invokeMethod
(
"attemptToResumeMsgFromWx"
);
}
@override
@override
Future
<
bool
>
get
isSupportOpenBusinessView
async
=>
Future
<
bool
>
get
isSupportOpenBusinessView
async
=>
await
methodChannel
.
invokeMethod
(
"checkSupportOpenBusinessView"
);
await
methodChannel
.
invokeMethod
(
"checkSupportOpenBusinessView"
);
...
...
lib/src/method_channel/fluwx_platform_interface.dart
浏览文件 @
ba1f5abe
...
@@ -113,6 +113,10 @@ abstract class FluwxPlatform extends PlatformInterface {
...
@@ -113,6 +113,10 @@ abstract class FluwxPlatform extends PlatformInterface {
throw
UnimplementedError
(
'authBy() has not been implemented.'
);
throw
UnimplementedError
(
'authBy() has not been implemented.'
);
}
}
Future
<
void
>
attemptToResumeMsgFromWx
()
{
throw
UnimplementedError
(
'authBy() has not been implemented.'
);
}
Future
<
bool
>
get
isSupportOpenBusinessView
async
{
Future
<
bool
>
get
isSupportOpenBusinessView
async
{
throw
UnimplementedError
(
throw
UnimplementedError
(
'isSupportOpenBusinessView() has not been implemented.'
);
'isSupportOpenBusinessView() has not been implemented.'
);
...
...
lib/src/response/wechat_response.dart
浏览文件 @
ba1f5abe
...
@@ -48,6 +48,8 @@ Map<String, _WeChatResponseInvoker> _nameAndResponseMapper = {
...
@@ -48,6 +48,8 @@ Map<String, _WeChatResponseInvoker> _nameAndResponseMapper = {
WeChatOpenBusinessViewResponse
.
fromMap
(
argument
),
WeChatOpenBusinessViewResponse
.
fromMap
(
argument
),
"onOpenWechatInvoiceResponse"
:
(
Map
argument
)
=>
"onOpenWechatInvoiceResponse"
:
(
Map
argument
)
=>
WeChatOpenInvoiceResponse
.
fromMap
(
argument
),
WeChatOpenInvoiceResponse
.
fromMap
(
argument
),
"onWXLaunchFromWX"
:
(
Map
argument
)
=>
WeChatLaunchFromWXRequest
.
fromMap
(
argument
),
};
};
sealed
class
WeChatResponse
{
sealed
class
WeChatResponse
{
...
@@ -213,8 +215,32 @@ class WeChatQRCodeScannedResponse extends WeChatResponse {
...
@@ -213,8 +215,32 @@ class WeChatQRCodeScannedResponse extends WeChatResponse {
// 获取微信打开App时携带的参数
// 获取微信打开App时携带的参数
class
WeChatShowMessageFromWXRequest
extends
WeChatResponse
{
class
WeChatShowMessageFromWXRequest
extends
WeChatResponse
{
final
String
?
country
;
final
String
?
lang
;
final
String
?
messageAction
;
final
String
?
description
;
WeChatShowMessageFromWXRequest
.
fromMap
(
Map
map
)
WeChatShowMessageFromWXRequest
.
fromMap
(
Map
map
)
:
extMsg
=
map
[
'extMsg'
],
:
extMsg
=
map
[
'extMsg'
],
country
=
map
[
'country'
],
messageAction
=
map
[
'messageAction'
],
description
=
map
[
"description"
],
lang
=
map
[
"lang"
],
super
.
_
(
0
,
''
);
final
String
?
extMsg
;
}
class
WeChatLaunchFromWXRequest
extends
WeChatResponse
{
final
String
?
country
;
final
String
?
lang
;
final
String
?
messageAction
;
WeChatLaunchFromWXRequest
.
fromMap
(
Map
map
)
:
extMsg
=
map
[
'extMsg'
],
country
=
map
[
'country'
],
messageAction
=
map
[
'messageAction'
],
lang
=
map
[
"lang"
],
super
.
_
(
0
,
''
);
super
.
_
(
0
,
''
);
final
String
?
extMsg
;
final
String
?
extMsg
;
...
...
test/fluwx_test.dart
浏览文件 @
ba1f5abe
...
@@ -90,6 +90,12 @@ class MockFluwxPlatform
...
@@ -90,6 +90,12 @@ class MockFluwxPlatform
throw
UnimplementedError
();
throw
UnimplementedError
();
}
}
@override
Future
<
void
>
attemptToResumeMsgFromWx
()
{
// TODO: implement attemptToResumeMsgFromWx
throw
UnimplementedError
();
}
}
}
void
main
(
)
{
void
main
(
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论