提交 68fd4181 authored 作者: lopo's avatar lopo

fix: Clarify the order in which methods are called to avoid missing events

上级 cc517508
...@@ -207,15 +207,31 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar; ...@@ -207,15 +207,31 @@ NSObject <FlutterPluginRegistrar> *_fluwxRegistrar;
} }
BOOL isWeChatRegistered = [WXApi registerApp:appId universalLink:universalLink]; BOOL isWeChatRegistered = [WXApi registerApp:appId universalLink:universalLink];
_isRunning = isWeChatRegistered;
// If registration fails, we can return immediately
if(!isWeChatRegistered){
result(@(isWeChatRegistered)); result(@(isWeChatRegistered));
_isRunning = NO;
return;
}
// handle the cached open url request (if any) immediately // Otherwise, since WXApi is now registered successfully,
// we can (and should) immediately handle the previously cached `app:openURL` event (if any)
if (_cachedOpenUrlRequest != nil) { if (_cachedOpenUrlRequest != nil) {
_cachedOpenUrlRequest(); _cachedOpenUrlRequest();
_cachedOpenUrlRequest = nil; _cachedOpenUrlRequest = nil;
} }
// Set `_isRunning` after calling `_cachedOpenUrlRequest` to ensure that
// the `onReq` triggered by this call to `_cachedOpenUrlRequest` will
// be stored in `_attemptToResumeMsgFromWxRunnable` which can be obtained
// by triggering `attemptToResumeMsgFromWx`.
//
// At the same time, this also coincides with the approach on the Android side:
// cold start events are cached and triggered through `attemptToResumeMsgFromWx`
_isRunning = isWeChatRegistered;
result(@(isWeChatRegistered));
} }
- (void)checkWeChatInstallation:(FlutterMethodCall *)call result:(FlutterResult)result { - (void)checkWeChatInstallation:(FlutterMethodCall *)call result:(FlutterResult)result {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论