Skip to content

Commit

Permalink
fix hotreload bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
dujiepeng committed May 19, 2023
1 parent 2806361 commit 7c98620
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## NEXT

## 4.0.0+6

- 修复 Hot reload 后回调执行多次的问题。

## 4.0.0+5

#### 修复
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

public class EMClientWrapper extends EMWrapper implements MethodCallHandler {

private EMOptions options;
static EMClientWrapper wrapper;
private EMChatManagerWrapper chatManagerWrapper;
private EMGroupManagerWrapper groupManagerWrapper;
Expand Down Expand Up @@ -279,13 +280,15 @@ private void kickAllDevices(JSONObject param, String channelName, Result result)
}

private void init(JSONObject param, String channelName, Result result) throws JSONException {
EMOptions options = EMOptionsHelper.fromJson(param, this.context);
if(options != null) return;
options = EMOptionsHelper.fromJson(param, this.context);
EMClient.getInstance().init(this.context, options);
EMClient.getInstance().setDebugMode(param.getBoolean("debugModel"));

bindingManagers();
registerEaseListener();
onSuccess(result, channelName, null);

}

private void renewToken(JSONObject param, String channelName, Result result) throws JSONException {
Expand Down
9 changes: 6 additions & 3 deletions ios/Classes/EMClientWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ @interface EMClientWrapper () <EMClientDelegate, EMMultiDevicesDelegate, Flutter
@end

@implementation EMClientWrapper
{
EMOptions *_options;
}

static EMClientWrapper *wrapper = nil;

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


if(_options != nil) return;
__weak typeof(self) weakSelf = self;

EMOptions *options = [EMOptions fromJson:param];
_options = [EMOptions fromJson:param];

[EMClient.sharedClient initializeSDKWithOptions:options];
[EMClient.sharedClient initializeSDKWithOptions:_options];

[EMClient.sharedClient addDelegate:self delegateQueue:nil];
[EMClient.sharedClient addMultiDevicesDelegate:self delegateQueue:nil];
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: im_flutter_sdk
description: Integrate the Chat SDK to enjoy the global IM services with high reliability, ultra-low latency, and high concurrency.
version: 4.0.0+5
version: 4.0.0+6
homepage: https://www.easemob.com/product/im

environment:
Expand Down

0 comments on commit 7c98620

Please sign in to comment.