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 个修改的文件
包含
96 行增加
和
8 行删除
+96
-8
FluwxPlugin.kt
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
+20
-0
FluwxRequestHandler.kt
...n/kotlin/com/jarvan/fluwx/handlers/FluwxRequestHandler.kt
+27
-4
FluwxPlugin.m
ios/Classes/FluwxPlugin.m
+0
-0
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
import
io.flutter.plugin.common.MethodChannel.MethodCallHandler
import
io.flutter.plugin.common.MethodChannel.Result
import
io.flutter.plugin.common.PluginRegistry
import
java.util.concurrent.atomic.AtomicBoolean
/** FluwxPlugin */
class
FluwxPlugin
:
FlutterPlugin
,
MethodCallHandler
,
ActivityAware
,
...
...
@@ -47,6 +49,9 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
private
var
fluwxChannel
:
MethodChannel
?
=
null
private
var
context
:
Context
?
=
null
private
val
attemptToResumeMsgFromWxFlag
=
AtomicBoolean
(
false
)
private
var
activityPluginBinding
:
ActivityPluginBinding
?
=
null
private
fun
handelIntent
(
intent
:
Intent
)
{
intent
.
getStringExtra
(
KEY_FLUWX_REQUEST_INFO_EXT_MSG
)
?.
let
{
...
...
@@ -96,10 +101,22 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
call
.
method
==
"openWeChatInvoice"
->
openWeChatInvoice
(
call
,
result
)
call
.
method
==
"openUrl"
->
openUrl
(
call
,
result
)
call
.
method
==
"openRankList"
->
openRankList
(
result
)
call
.
method
==
"attemptToResumeMsgFromWx"
->
attemptToResumeMsgFromWx
(
result
)
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
)
{
if
(
WXAPiHandler
.
wxApi
==
null
)
{
result
.
error
(
"Unassigned WxApi"
,
"please config wxapi first"
,
null
)
...
...
@@ -127,6 +144,7 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
override
fun
onDetachedFromEngine
(
@NonNull
binding
:
FlutterPlugin
.
FlutterPluginBinding
)
{
shareHandler
?.
onDestroy
()
authHandler
?.
removeAllListeners
()
activityPluginBinding
=
null
}
override
fun
onDetachedFromActivity
()
{
...
...
@@ -141,6 +159,7 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
override
fun
onAttachedToActivity
(
binding
:
ActivityPluginBinding
)
{
// WXAPiHandler.setContext(binding.activity.applicationContext)
activityPluginBinding
=
binding
handelIntent
(
binding
.
activity
.
intent
)
FluwxRequestHandler
.
handleRequestInfoFromIntent
(
binding
.
activity
.
intent
)
shareHandler
?.
permissionHandler
=
PermissionHandler
(
binding
.
activity
)
...
...
@@ -287,6 +306,7 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
result
.
success
(
false
)
}
}
private
fun
openRankList
(
result
:
Result
)
{
val
req
=
OpenRankList
.
Req
()
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
import
com.jarvan.fluwx.utils.KEY_FLUWX_REQUEST_INFO_EXT_MSG
import
com.jarvan.fluwx.utils.startFlutterActivity
import
com.tencent.mm.opensdk.modelbase.BaseReq
import
com.tencent.mm.opensdk.modelmsg.LaunchFromWX
import
com.tencent.mm.opensdk.modelmsg.ShowMessageFromWX
import
java.security.cert.Extension
...
...
@@ -42,6 +43,8 @@ object FluwxRequestHandler {
val
type
=
getInt
(
"_wxapi_command_type"
,
-
9999
)
if
(
type
==
4
)
{
handleShowMessageFromWXBundle
(
this
)
}
else
if
(
type
==
6
)
{
handleWXLaunchFromWXBundle
(
this
)
}
}
}
...
...
@@ -49,24 +52,44 @@ object FluwxRequestHandler {
private
fun
handleShowMessageFromWXBundle
(
bundle
:
Bundle
)
=
handleWXShowMessageFromWX
(
ShowMessageFromWX
.
Req
(
bundle
))
private
fun
handleWXLaunchFromWXBundle
(
bundle
:
Bundle
)
=
handleWXLaunchFromWX
(
LaunchFromWX
.
Req
(
bundle
))
private
fun
handleRequest
(
req
:
BaseReq
)
{
when
(
req
)
{
is
ShowMessageFromWX
.
Req
->
handleWXShowMessageFromWX
(
req
)
is
LaunchFromWX
.
Req
->
handleWXLaunchFromWX
(
req
)
}
}
private
fun
handleWXShowMessageFromWX
(
req
:
ShowMessageFromWX
.
Req
)
{
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
)
}
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
)
{
// FIXME: 可能是官方的Bug,从微信拉起APP的Intent类型不对,无法跳转回Flutter Activity
// 稳定复现场景:微信版本为7.0.5,小程序SDK为2.7.7
if
(
baseReq
.
type
==
4
)
{
// com.tencent.mm.opensdk.constants.ConstantsAPI.COMMAND_SHOWMESSAGE_FROM_WX = 4
if
(!
WXAPiHandler
.
coolBoot
)
{
handleRequest
(
baseReq
)
...
...
@@ -87,7 +110,7 @@ object FluwxRequestHandler {
WXAPiHandler
.
coolBoot
=
false
}
}
}
}
}
...
...
ios/Classes/FluwxPlugin.m
浏览文件 @
ba1f5abe
差异被折叠。
点击展开。
ios/fluwx.podspec
浏览文件 @
ba1f5abe
...
...
@@ -69,7 +69,7 @@ The capability of implementing WeChat SDKs in Flutter. With Fluwx, developers ca
end
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
.
libraries
=
'c++'
,
'z'
,
'sqlite3.0'
if
debug_logging
...
...
lib/src/fluwx.dart
浏览文件 @
ba1f5abe
...
...
@@ -94,6 +94,12 @@ class Fluwx {
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
subscribeResponse
(
Function
(
WeChatResponse
response
)
listener
)
{
_responseListeners
.
add
(
listener
);
...
...
lib/src/method_channel/fluwx_method_channel.dart
浏览文件 @
ba1f5abe
...
...
@@ -183,9 +183,7 @@ class MethodChannelFluwx extends FluwxPlatform {
switch
(
which
)
{
case
Payment
():
return
await
methodChannel
.
invokeMethod
(
'payWithFluwx'
,
which
.
arguments
);
'payWithFluwx'
,
which
.
arguments
);
case
HongKongWallet
():
return
await
methodChannel
.
invokeMethod
(
'payWithHongKongWallet'
,
which
.
arguments
);
...
...
@@ -205,6 +203,11 @@ class MethodChannelFluwx extends FluwxPlatform {
return
await
methodChannel
.
invokeMethod
(
'stopAuthByQRCode'
);
}
@override
Future
<
void
>
attemptToResumeMsgFromWx
()
async
{
return
await
methodChannel
.
invokeMethod
(
"attemptToResumeMsgFromWx"
);
}
@override
Future
<
bool
>
get
isSupportOpenBusinessView
async
=>
await
methodChannel
.
invokeMethod
(
"checkSupportOpenBusinessView"
);
...
...
lib/src/method_channel/fluwx_platform_interface.dart
浏览文件 @
ba1f5abe
...
...
@@ -113,6 +113,10 @@ abstract class FluwxPlatform extends PlatformInterface {
throw
UnimplementedError
(
'authBy() has not been implemented.'
);
}
Future
<
void
>
attemptToResumeMsgFromWx
()
{
throw
UnimplementedError
(
'authBy() has not been implemented.'
);
}
Future
<
bool
>
get
isSupportOpenBusinessView
async
{
throw
UnimplementedError
(
'isSupportOpenBusinessView() has not been implemented.'
);
...
...
lib/src/response/wechat_response.dart
浏览文件 @
ba1f5abe
...
...
@@ -48,6 +48,8 @@ Map<String, _WeChatResponseInvoker> _nameAndResponseMapper = {
WeChatOpenBusinessViewResponse
.
fromMap
(
argument
),
"onOpenWechatInvoiceResponse"
:
(
Map
argument
)
=>
WeChatOpenInvoiceResponse
.
fromMap
(
argument
),
"onWXLaunchFromWX"
:
(
Map
argument
)
=>
WeChatLaunchFromWXRequest
.
fromMap
(
argument
),
};
sealed
class
WeChatResponse
{
...
...
@@ -213,8 +215,32 @@ class WeChatQRCodeScannedResponse extends WeChatResponse {
// 获取微信打开App时携带的参数
class
WeChatShowMessageFromWXRequest
extends
WeChatResponse
{
final
String
?
country
;
final
String
?
lang
;
final
String
?
messageAction
;
final
String
?
description
;
WeChatShowMessageFromWXRequest
.
fromMap
(
Map
map
)
:
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
,
''
);
final
String
?
extMsg
;
...
...
test/fluwx_test.dart
浏览文件 @
ba1f5abe
...
...
@@ -90,6 +90,12 @@ class MockFluwxPlatform
throw
UnimplementedError
();
}
@override
Future
<
void
>
attemptToResumeMsgFromWx
()
{
// TODO: implement attemptToResumeMsgFromWx
throw
UnimplementedError
();
}
}
void
main
(
)
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论