Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
flutter_push
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
顾海波
2025-01-22 17:58:21 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a9590182b0d043970b995d9aca25722206f205d2
a9590182
1 parent
6a4b829d
【修复】app关闭后收到消息启动
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
2 deletions
android/src/main/kotlin/com/ewin/flutter_push/EwinMixPushReceiver.kt
android/src/main/kotlin/com/ewin/flutter_push/FlutterPushPlugin.kt
android/src/main/kotlin/com/ewin/flutter_push/EwinMixPushReceiver.kt
View file @
a959018
...
...
@@ -32,8 +32,10 @@ class EwinMixPushReceiver : MixPushReceiver() {
}
override fun onNotificationMessageClicked(context: Context, message: MixPushMessage) {
if(!::FlutterPushPlugin.channel.isInitialized){
if(!FlutterPushPlugin.isInit()){
FlutterPushPlugin.lastMsg = message
context.startActivity(context.packageManager.getLaunchIntentForPackage(context.packageName))
return
}
this.invokeListener(MixListenerTypeEnum.NotificationMessageClicked, message)
...
...
android/src/main/kotlin/com/ewin/flutter_push/FlutterPushPlugin.kt
View file @
a959018
...
...
@@ -17,7 +17,7 @@ import com.ewin.flutter_push.EwinMixPushReceiver
import com.ewin.flutter_push.enums.MixListenerTypeEnum
import com.ewin.flutter_push.utils.CommonUtil
import com.alibaba.fastjson.JSON
import com.mixpush.core.MixPushMessage
/** FlutterPushPlugin */
class FlutterPushPlugin: FlutterPlugin, MethodCallHandler {
/// The MethodChannel that will the communication between Flutter and native Android
...
...
@@ -26,6 +26,10 @@ class FlutterPushPlugin: FlutterPlugin, MethodCallHandler {
/// when the Flutter Engine is detached from the Activity
companion object {
lateinit var channel: MethodChannel
var lastMsg :MixPushMessage ? = null
fun isInit():Boolean{
return ::channel.isInitialized
}
}
private lateinit var context: Context
...
...
@@ -43,6 +47,18 @@ class FlutterPushPlugin: FlutterPlugin, MethodCallHandler {
MixPushClient.getInstance().setPushReceiver(EwinMixPushReceiver())
MixPushClient.getInstance().register(this.context,defaultPlatform?:HUAWEI)
result.success(true)
CommonUtil.runMainThread {
if(lastMsg!=null){
val p: String = if (lastMsg != null) JSON.toJSONString(lastMsg) else ""
channel.invokeMethod("onListener", mapOf(
"type" to MixListenerTypeEnum.NotificationMessageClicked.name,
"params" to p
))
lastMsg = null
}
}
} else if (call.method == "getRegId") {
MixPushClient.getInstance().getRegisterId(this.context, object : GetRegisterIdCallback() {
override fun callback(platform: MixPushPlatform?) {
...
...
Please
register
or
login
to post a comment