Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
7b49a11b
提交
7b49a11b
authored
4月 12, 2021
作者:
Charley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
通过url scheme方式传递冷启动参数
上级
58eeebf9
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
37 行增加
和
9 行删除
+37
-9
FluwxPlugin.kt
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
+18
-1
FluwxRequestHandler.kt
...n/kotlin/com/jarvan/fluwx/handlers/FluwxRequestHandler.kt
+19
-8
没有找到文件。
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
浏览文件 @
7b49a11b
package
com.jarvan.fluwx
import
android.content.Intent
import
android.util.Log
import
androidx.annotation.NonNull
import
com.jarvan.fluwx.handlers.*
import
com.tencent.mm.opensdk.modelbiz.SubscribeMessage
...
...
@@ -16,7 +18,7 @@ import io.flutter.plugin.common.MethodChannel.Result
import
io.flutter.plugin.common.PluginRegistry
/** FluwxPlugin */
class
FluwxPlugin
:
FlutterPlugin
,
MethodCallHandler
,
ActivityAware
{
class
FluwxPlugin
:
FlutterPlugin
,
MethodCallHandler
,
ActivityAware
,
PluginRegistry
.
NewIntentListener
{
companion
object
{
...
...
@@ -45,6 +47,14 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
private
var
fluwxChannel
:
MethodChannel
?
=
null
private
fun
handelIntent
(
intent
:
Intent
?){
val
action
=
intent
?.
action
val
dataString
=
intent
?.
dataString
if
(
Intent
.
ACTION_VIEW
.
equals
(
action
))
{
extMsg
=
dataString
}
}
override
fun
onAttachedToEngine
(
@NonNull
flutterPluginBinding
:
FlutterPlugin
.
FlutterPluginBinding
)
{
val
channel
=
MethodChannel
(
flutterPluginBinding
.
binaryMessenger
,
"com.jarvanmo/fluwx"
)
channel
.
setMethodCallHandler
(
this
)
...
...
@@ -84,10 +94,12 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
override
fun
onReattachedToActivityForConfigChanges
(
binding
:
ActivityPluginBinding
)
{
shareHandler
?.
permissionHandler
=
PermissionHandler
(
binding
.
activity
)
handelIntent
(
binding
.
activity
.
intent
)
}
override
fun
onAttachedToActivity
(
binding
:
ActivityPluginBinding
)
{
WXAPiHandler
.
setContext
(
binding
.
activity
.
applicationContext
)
handelIntent
(
binding
.
activity
.
intent
)
shareHandler
?.
permissionHandler
=
PermissionHandler
(
binding
.
activity
)
}
...
...
@@ -194,4 +206,9 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
}
private
fun
openWXApp
(
result
:
MethodChannel
.
Result
)
=
result
.
success
(
WXAPiHandler
.
wxApi
?.
openWXApp
())
override
fun
onNewIntent
(
intent
:
Intent
?):
Boolean
{
handelIntent
(
intent
)
return
false
}
}
android/src/main/kotlin/com/jarvan/fluwx/handlers/FluwxRequestHandler.kt
浏览文件 @
7b49a11b
...
...
@@ -19,13 +19,15 @@ import android.app.Activity
import
android.content.Context
import
android.content.Intent
import
android.content.pm.PackageManager
import
android.net.Uri
import
android.os.Bundle
import
android.util.Log
import
androidx.core.content.ContextCompat.startActivity
import
com.jarvan.fluwx.FluwxPlugin
import
com.tencent.mm.opensdk.modelmsg.ShowMessageFromWX
import
io.flutter.plugin.common.MethodChannel
import
com.tencent.mm.opensdk.modelbase.BaseReq
import
java.lang.Exception
import
com.tencent.mm.opensdk.modelmsg.ShowMessageFromWX
import
java.security.cert.Extension
object
FluwxRequestHandler
{
private
const
val
KEY_FLUWX_REQUEST_INFO_BUNDLE
=
"KEY_FLUWX_REQUEST_INFO_BUNDLE"
...
...
@@ -53,7 +55,6 @@ object FluwxRequestHandler {
val
result
=
mapOf
(
"extMsg"
to
req
.
message
.
messageExt
)
FluwxPlugin
.
extMsg
=
req
.
message
.
messageExt
;
FluwxPlugin
.
callingChannel
?.
invokeMethod
(
"onWXShowMessageFromWX"
,
result
)
}
...
...
@@ -66,9 +67,19 @@ object FluwxRequestHandler {
handleRequest
(
baseReq
)
startSpecifiedActivity
(
defaultFlutterActivityAction
(
activity
),
activity
=
activity
)
}
else
{
startSpecifiedActivity
(
defaultFlutterActivityAction
(
activity
),
bundle
=
Bundle
().
apply
{
baseReq
.
toBundle
(
this
)
},
bundleKey
=
KEY_FLUWX_REQUEST_INFO_BUNDLE
,
activity
=
activity
)
when
(
baseReq
)
{
is
ShowMessageFromWX
.
Req
->
{
try
{
val
intent
=
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
"wechatextmsg://${activity.packageName}/?extmsg=${baseReq.message.messageExt}"
))
activity
.
startActivity
(
intent
)
activity
.
finish
()
WXAPiHandler
.
setCoolBool
(
false
)
}
catch
(
e
:
Exception
)
{
Log
.
i
(
"fluwx"
,
"call scheme error:${e.toString()}"
)
}
}
}
}
}
}
...
...
@@ -76,7 +87,7 @@ object FluwxRequestHandler {
fun
onReq
(
baseReq
:
BaseReq
,
activity
:
Activity
)
{
try
{
val
packageManager
=
activity
.
packageManager
var
appInfo
=
packageManager
.
getApplicationInfo
(
activity
.
packageName
,
PackageManager
.
GET_META_DATA
)
var
appInfo
=
packageManager
.
getApplicationInfo
(
activity
.
packageName
,
PackageManager
.
GET_META_DATA
)
val
defaultHandle
=
appInfo
.
metaData
.
getBoolean
(
"handleWeChatRequestByFluwx"
,
true
)
if
(
defaultHandle
)
{
defaultOnReqDelegate
(
baseReq
,
activity
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论