Showing
2 changed files
with
20 additions
and
2 deletions
| @@ -32,8 +32,10 @@ class EwinMixPushReceiver : MixPushReceiver() { | @@ -32,8 +32,10 @@ class EwinMixPushReceiver : MixPushReceiver() { | ||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | override fun onNotificationMessageClicked(context: Context, message: MixPushMessage) { | 34 | override fun onNotificationMessageClicked(context: Context, message: MixPushMessage) { |
| 35 | - if(!::FlutterPushPlugin.channel.isInitialized){ | 35 | + if(!FlutterPushPlugin.isInit()){ |
| 36 | + FlutterPushPlugin.lastMsg = message | ||
| 36 | context.startActivity(context.packageManager.getLaunchIntentForPackage(context.packageName)) | 37 | context.startActivity(context.packageManager.getLaunchIntentForPackage(context.packageName)) |
| 38 | + return | ||
| 37 | } | 39 | } |
| 38 | this.invokeListener(MixListenerTypeEnum.NotificationMessageClicked, message) | 40 | this.invokeListener(MixListenerTypeEnum.NotificationMessageClicked, message) |
| 39 | 41 |
| @@ -17,7 +17,7 @@ import com.ewin.flutter_push.EwinMixPushReceiver | @@ -17,7 +17,7 @@ import com.ewin.flutter_push.EwinMixPushReceiver | ||
| 17 | import com.ewin.flutter_push.enums.MixListenerTypeEnum | 17 | import com.ewin.flutter_push.enums.MixListenerTypeEnum |
| 18 | import com.ewin.flutter_push.utils.CommonUtil | 18 | import com.ewin.flutter_push.utils.CommonUtil |
| 19 | import com.alibaba.fastjson.JSON | 19 | import com.alibaba.fastjson.JSON |
| 20 | - | 20 | +import com.mixpush.core.MixPushMessage |
| 21 | /** FlutterPushPlugin */ | 21 | /** FlutterPushPlugin */ |
| 22 | class FlutterPushPlugin: FlutterPlugin, MethodCallHandler { | 22 | class FlutterPushPlugin: FlutterPlugin, MethodCallHandler { |
| 23 | /// The MethodChannel that will the communication between Flutter and native Android | 23 | /// The MethodChannel that will the communication between Flutter and native Android |
| @@ -26,6 +26,10 @@ class FlutterPushPlugin: FlutterPlugin, MethodCallHandler { | @@ -26,6 +26,10 @@ class FlutterPushPlugin: FlutterPlugin, MethodCallHandler { | ||
| 26 | /// when the Flutter Engine is detached from the Activity | 26 | /// when the Flutter Engine is detached from the Activity |
| 27 | companion object { | 27 | companion object { |
| 28 | lateinit var channel: MethodChannel | 28 | lateinit var channel: MethodChannel |
| 29 | + var lastMsg :MixPushMessage ? = null | ||
| 30 | + fun isInit():Boolean{ | ||
| 31 | + return ::channel.isInitialized | ||
| 32 | + } | ||
| 29 | } | 33 | } |
| 30 | private lateinit var context: Context | 34 | private lateinit var context: Context |
| 31 | 35 | ||
| @@ -43,6 +47,18 @@ class FlutterPushPlugin: FlutterPlugin, MethodCallHandler { | @@ -43,6 +47,18 @@ class FlutterPushPlugin: FlutterPlugin, MethodCallHandler { | ||
| 43 | MixPushClient.getInstance().setPushReceiver(EwinMixPushReceiver()) | 47 | MixPushClient.getInstance().setPushReceiver(EwinMixPushReceiver()) |
| 44 | MixPushClient.getInstance().register(this.context,defaultPlatform?:HUAWEI) | 48 | MixPushClient.getInstance().register(this.context,defaultPlatform?:HUAWEI) |
| 45 | result.success(true) | 49 | result.success(true) |
| 50 | + | ||
| 51 | + CommonUtil.runMainThread { | ||
| 52 | + if(lastMsg!=null){ | ||
| 53 | + val p: String = if (lastMsg != null) JSON.toJSONString(lastMsg) else "" | ||
| 54 | + channel.invokeMethod("onListener", mapOf( | ||
| 55 | + "type" to MixListenerTypeEnum.NotificationMessageClicked.name, | ||
| 56 | + "params" to p | ||
| 57 | + )) | ||
| 58 | + lastMsg = null | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + | ||
| 46 | } else if (call.method == "getRegId") { | 62 | } else if (call.method == "getRegId") { |
| 47 | MixPushClient.getInstance().getRegisterId(this.context, object : GetRegisterIdCallback() { | 63 | MixPushClient.getInstance().getRegisterId(this.context, object : GetRegisterIdCallback() { |
| 48 | override fun callback(platform: MixPushPlatform?) { | 64 | override fun callback(platform: MixPushPlatform?) { |
-
Please register or login to post a comment