Skip to content

Commit 7c98620

Browse files
committed
fix hotreload bugs.
1 parent 2806361 commit 7c98620

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## NEXT
22

3+
## 4.0.0+6
4+
5+
- 修复 Hot reload 后回调执行多次的问题。
6+
37
## 4.0.0+5
48

59
#### 修复

android/src/main/java/com/easemob/im_flutter_sdk/EMClientWrapper.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
public class EMClientWrapper extends EMWrapper implements MethodCallHandler {
3232

33+
private EMOptions options;
3334
static EMClientWrapper wrapper;
3435
private EMChatManagerWrapper chatManagerWrapper;
3536
private EMGroupManagerWrapper groupManagerWrapper;
@@ -279,13 +280,15 @@ private void kickAllDevices(JSONObject param, String channelName, Result result)
279280
}
280281

281282
private void init(JSONObject param, String channelName, Result result) throws JSONException {
282-
EMOptions options = EMOptionsHelper.fromJson(param, this.context);
283+
if(options != null) return;
284+
options = EMOptionsHelper.fromJson(param, this.context);
283285
EMClient.getInstance().init(this.context, options);
284286
EMClient.getInstance().setDebugMode(param.getBoolean("debugModel"));
285287

286288
bindingManagers();
287289
registerEaseListener();
288290
onSuccess(result, channelName, null);
291+
289292
}
290293

291294
private void renewToken(JSONObject param, String channelName, Result result) throws JSONException {

ios/Classes/EMClientWrapper.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ @interface EMClientWrapper () <EMClientDelegate, EMMultiDevicesDelegate, Flutter
3939
@end
4040

4141
@implementation EMClientWrapper
42+
{
43+
EMOptions *_options;
44+
}
4245

4346
static EMClientWrapper *wrapper = nil;
4447

@@ -183,12 +186,12 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
183186
#pragma mark - Actions
184187
- (void)initSDKWithDict:(NSDictionary *)param channelName:(NSString *)aChannelName result:(FlutterResult)result {
185188

186-
189+
if(_options != nil) return;
187190
__weak typeof(self) weakSelf = self;
188191

189-
EMOptions *options = [EMOptions fromJson:param];
192+
_options = [EMOptions fromJson:param];
190193

191-
[EMClient.sharedClient initializeSDKWithOptions:options];
194+
[EMClient.sharedClient initializeSDKWithOptions:_options];
192195

193196
[EMClient.sharedClient addDelegate:self delegateQueue:nil];
194197
[EMClient.sharedClient addMultiDevicesDelegate:self delegateQueue:nil];

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: im_flutter_sdk
22
description: Integrate the Chat SDK to enjoy the global IM services with high reliability, ultra-low latency, and high concurrency.
3-
version: 4.0.0+5
3+
version: 4.0.0+6
44
homepage: https://www.easemob.com/product/im
55

66
environment:

0 commit comments

Comments
 (0)