zhuguoming
@@ -32,12 +32,12 @@ class EwinMixPushReceiver : MixPushReceiver() { @@ -32,12 +32,12 @@ 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.isInit()){  
36 - FlutterPushPlugin.lastMsg = message  
37 - context.startActivity(context.packageManager.getLaunchIntentForPackage(context.packageName))  
38 - return 35 +
  36 + FlutterPushPlugin.lastMsg = message
  37 + context.startActivity(context.packageManager.getLaunchIntentForPackage(context.packageName))
  38 + if(FlutterPushPlugin.isInit()){
  39 + this.invokeListener(MixListenerTypeEnum.NotificationMessageClicked, message)
39 } 40 }
40 - this.invokeListener(MixListenerTypeEnum.NotificationMessageClicked, message)  
41 41
42 // var intent: Intent? = null 42 // var intent: Intent? = null
43 // if (message.payload == null) { 43 // if (message.payload == null) {
@@ -25,7 +25,7 @@ import android.content.Intent; @@ -25,7 +25,7 @@ import android.content.Intent;
25 import android.net.Uri; 25 import android.net.Uri;
26 import android.os.Build; 26 import android.os.Build;
27 import android.provider.Settings; 27 import android.provider.Settings;
28 - 28 +import android.util.Log
29 29
30 30
31 /** FlutterPushPlugin */ 31 /** FlutterPushPlugin */
@@ -50,6 +50,10 @@ class FlutterPushPlugin: FlutterPlugin, MethodCallHandler { @@ -50,6 +50,10 @@ class FlutterPushPlugin: FlutterPlugin, MethodCallHandler {
50 } 50 }
51 51
52 override fun onMethodCall(call: MethodCall, result: Result) { 52 override fun onMethodCall(call: MethodCall, result: Result) {
  53 +
  54 +
  55 + Log.d("onMethodCall", "${call.method}")
  56 +
53 if (call.method == "getPlatformVersion") { 57 if (call.method == "getPlatformVersion") {
54 result.success("Android ${android.os.Build.VERSION.RELEASE}") 58 result.success("Android ${android.os.Build.VERSION.RELEASE}")
55 } else if (call.method == "init") { 59 } else if (call.method == "init") {
@@ -83,6 +87,9 @@ class FlutterPushPlugin: FlutterPlugin, MethodCallHandler { @@ -83,6 +87,9 @@ class FlutterPushPlugin: FlutterPlugin, MethodCallHandler {
83 NotificationManagerUtils.openPermissionSetting(context) 87 NotificationManagerUtils.openPermissionSetting(context)
84 } 88 }
85 result.success(true) 89 result.success(true)
  90 + } else if (call.method == "msgReceive") {
  91 + lastMsg = null
  92 + result.success(true)
86 } else { 93 } else {
87 result.notImplemented() 94 result.notImplemented()
88 } 95 }
@@ -8,7 +8,7 @@ class FlutterPush { @@ -8,7 +8,7 @@ class FlutterPush {
8 return FlutterPushPlatform.instance.getPlatformVersion(); 8 return FlutterPushPlatform.instance.getPlatformVersion();
9 } 9 }
10 10
11 - Future<void> init({ 11 + Future<bool> init({
12 String? defaultPlatform, 12 String? defaultPlatform,
13 String? appId, 13 String? appId,
14 String? appKey, 14 String? appKey,
@@ -31,4 +31,8 @@ class FlutterPush { @@ -31,4 +31,8 @@ class FlutterPush {
31 void removeListener(ListenerValue func) { 31 void removeListener(ListenerValue func) {
32 FlutterPushPlatform.instance.removeListener(func); 32 FlutterPushPlatform.instance.removeListener(func);
33 } 33 }
  34 +
  35 + void msgReceive() {
  36 + FlutterPushPlatform.instance.msgReceive();
  37 + }
34 } 38 }
@@ -21,7 +21,7 @@ class MethodChannelFlutterPush extends FlutterPushPlatform { @@ -21,7 +21,7 @@ class MethodChannelFlutterPush extends FlutterPushPlatform {
21 /// 初始化,如果没有appId或appKey,请登录小米开发者中心申请 21 /// 初始化,如果没有appId或appKey,请登录小米开发者中心申请
22 /// [appId] 应用appId 22 /// [appId] 应用appId
23 /// [appKey] 应用appKey 23 /// [appKey] 应用appKey
24 - Future<void> init({ 24 + Future<bool> init({
25 String? defaultPlatform, 25 String? defaultPlatform,
26 String? appId, 26 String? appId,
27 String? appKey, 27 String? appKey,
@@ -57,4 +57,9 @@ class MethodChannelFlutterPush extends FlutterPushPlatform { @@ -57,4 +57,9 @@ class MethodChannelFlutterPush extends FlutterPushPlatform {
57 Future<String?> getRegId() async { 57 Future<String?> getRegId() async {
58 return await methodChannel.invokeMethod('getRegId'); 58 return await methodChannel.invokeMethod('getRegId');
59 } 59 }
  60 +
  61 + /// 获取客户端的 RegId
  62 + Future<bool> msgReceive() async {
  63 + return await methodChannel.invokeMethod('msgReceive');
  64 + }
60 } 65 }
@@ -28,39 +28,42 @@ abstract class FlutterPushPlatform extends PlatformInterface { @@ -28,39 +28,42 @@ abstract class FlutterPushPlatform extends PlatformInterface {
28 throw UnimplementedError('platformVersion() has not been implemented.'); 28 throw UnimplementedError('platformVersion() has not been implemented.');
29 } 29 }
30 30
31 -  
32 -  
33 /// 初始化,如果没有appId或appKey,请登录小米开发者中心申请 31 /// 初始化,如果没有appId或appKey,请登录小米开发者中心申请
34 /// [appId] 应用appId 32 /// [appId] 应用appId
35 /// [appKey] 应用appKey 33 /// [appKey] 应用appKey
36 - Future<void> init({ 34 + Future<bool> init({
37 String? defaultPlatform, 35 String? defaultPlatform,
38 String? appId, 36 String? appId,
39 String? appKey, 37 String? appKey,
40 }) async { 38 }) async {
41 - throw UnimplementedError('platformVersion() has not been implemented.'); 39 + throw UnimplementedError('init() has not been implemented.');
42 } 40 }
43 41
44 Future<bool> checkPermission() async { 42 Future<bool> checkPermission() async {
45 - throw UnimplementedError('platformVersion() has not been implemented.'); 43 + throw UnimplementedError('checkPermission() has not been implemented.');
46 } 44 }
47 45
48 Future<bool> getPermission() async { 46 Future<bool> getPermission() async {
49 - throw UnimplementedError('platformVersion() has not been implemented.'); 47 + throw UnimplementedError('getPermission() has not been implemented.');
50 } 48 }
51 49
52 /// 添加消息监听 50 /// 添加消息监听
53 void addListener(ListenerValue func) { 51 void addListener(ListenerValue func) {
54 - throw UnimplementedError('platformVersion() has not been implemented.'); 52 + throw UnimplementedError('addListener() has not been implemented.');
55 } 53 }
56 54
57 /// 移除消息监听 55 /// 移除消息监听
58 void removeListener(ListenerValue func) { 56 void removeListener(ListenerValue func) {
59 - throw UnimplementedError('platformVersion() has not been implemented.'); 57 + throw UnimplementedError('removeListener() has not been implemented.');
60 } 58 }
61 59
62 /// 获取客户端的 RegId 60 /// 获取客户端的 RegId
63 Future<String?> getRegId() async { 61 Future<String?> getRegId() async {
64 - throw UnimplementedError('platformVersion() has not been implemented.'); 62 + throw UnimplementedError('getRegId() has not been implemented.');
  63 + }
  64 +
  65 + /// 获取客户端的 RegId
  66 + Future<bool> msgReceive() async {
  67 + throw UnimplementedError('msgReceive() has not been implemented.');
65 } 68 }
66 } 69 }