fix runnable

This commit is contained in:
JarvanMo
2023-05-19 23:11:29 +08:00
parent 7c97d2d90d
commit 9ada18081c
2 changed files with 6 additions and 11 deletions

View File

@ -2,14 +2,12 @@ package com.jarvan.fluwx
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import androidx.annotation.NonNull
import com.jarvan.fluwx.handlers.FluwxAuthHandler import com.jarvan.fluwx.handlers.FluwxAuthHandler
import com.jarvan.fluwx.handlers.FluwxRequestHandler import com.jarvan.fluwx.handlers.FluwxRequestHandler
import com.jarvan.fluwx.handlers.FluwxShareHandler import com.jarvan.fluwx.handlers.FluwxShareHandler
import com.jarvan.fluwx.handlers.FluwxShareHandlerEmbedding import com.jarvan.fluwx.handlers.FluwxShareHandlerEmbedding
import com.jarvan.fluwx.handlers.PermissionHandler import com.jarvan.fluwx.handlers.PermissionHandler
import com.jarvan.fluwx.handlers.WXAPiHandler import com.jarvan.fluwx.handlers.WXAPiHandler
import com.jarvan.fluwx.utils.KEY_FLUWX_REQUEST_INFO_EXT_MSG
import com.jarvan.fluwx.utils.WXApiUtils import com.jarvan.fluwx.utils.WXApiUtils
import com.jarvan.fluwx.utils.readWeChatCallbackIntent import com.jarvan.fluwx.utils.readWeChatCallbackIntent
import com.tencent.mm.opensdk.modelbase.BaseReq import com.tencent.mm.opensdk.modelbase.BaseReq
@ -362,8 +360,8 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
req?.let { req?.let {
if (FluwxConfigurations.interruptWeChatRequestByFluwx) { if (FluwxConfigurations.interruptWeChatRequestByFluwx) {
when (req) { when (req) {
is ShowMessageFromWX.Req -> handleWXShowMessageFromWX(req) is ShowMessageFromWX.Req -> handleShowMessageFromWX(req)
is LaunchFromWX.Req -> handleWXLaunchFromWX(req) is LaunchFromWX.Req -> handleLaunchFromWX(req)
else -> {} else -> {}
} }
} else { } else {
@ -374,7 +372,7 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
} }
private fun handleWXShowMessageFromWX(req: ShowMessageFromWX.Req) { private fun handleShowMessageFromWX(req: ShowMessageFromWX.Req) {
val result = mapOf( val result = mapOf(
"extMsg" to req.message.messageExt, "extMsg" to req.message.messageExt,
"messageAction" to req.message.messageAction, "messageAction" to req.message.messageAction,
@ -387,13 +385,14 @@ class FluwxPlugin : FlutterPlugin, MethodCallHandler, ActivityAware,
fluwxChannel?.invokeMethod("onWXShowMessageFromWX", result) fluwxChannel?.invokeMethod("onWXShowMessageFromWX", result)
} }
private fun handleWXLaunchFromWX(req: LaunchFromWX.Req) { private fun handleLaunchFromWX(req: LaunchFromWX.Req) {
val result = mapOf( val result = mapOf(
"extMsg" to req.messageExt, "extMsg" to req.messageExt,
"messageAction" to req.messageAction, "messageAction" to req.messageAction,
"lang" to req.lang, "lang" to req.lang,
"country" to req.country, "country" to req.country,
) )
extMsg = req.message.messageExt
fluwxChannel?.invokeMethod("onWXLaunchFromWX", result) fluwxChannel?.invokeMethod("onWXLaunchFromWX", result)
} }

View File

@ -58,10 +58,6 @@ const NSString *lang = @"lang";
const NSString *country = @"country"; const NSString *country = @"country";
const NSString *description = @"description"; const NSString *description = @"description";
FluwxWXReqRunnable _initialWXReqRunnable;
BOOL handleOpenURLByFluwx = YES; BOOL handleOpenURLByFluwx = YES;
NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
@ -1036,7 +1032,7 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
[_channel invokeMethod:@"onWXShowMessageFromWX" arguments:result]; [_channel invokeMethod:@"onWXShowMessageFromWX" arguments:result];
} else { } else {
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
_initialWXReqRunnable = ^() { _attemptToResumeMsgFromWxRunnable = ^() {
__strong typeof(weakSelf) strongSelf = weakSelf; __strong typeof(weakSelf) strongSelf = weakSelf;
[strongSelf->_channel invokeMethod:@"onWXShowMessageFromWX" arguments:result]; [strongSelf->_channel invokeMethod:@"onWXShowMessageFromWX" arguments:result];
}; };