@@ -150,6 +150,7 @@ public void login(String contactId, String token, final Promise promise) {
150150// LogUtil.w(TAG, "md5:" + MD5.getStringMD5(token));
151151
152152 NIMClient .getService (AuthService .class ).openLocalCache (contactId );
153+ LogUtil .w (TAG , "s:" + NIMClient .getStatus ().name ());
153154 LoginService .getInstance ().login (new LoginInfo (contactId , token ), new RequestCallback <LoginInfo >() {
154155 @ Override
155156 public void onSuccess (LoginInfo loginInfo ) {
@@ -174,7 +175,6 @@ public void onException(Throwable throwable) {
174175
175176 }
176177 });
177-
178178 }
179179
180180 /**
@@ -183,6 +183,7 @@ public void onException(Throwable throwable) {
183183 @ ReactMethod
184184 public void logout () {
185185 LogUtil .w (TAG , "logout" );
186+ status = "" ;
186187 LoginService .getInstance ().logout ();
187188
188189 }
@@ -1385,7 +1386,22 @@ public void onResult(int code, Void aVoid, Throwable throwable) {
13851386 @ ReactMethod
13861387 public void resendMessage (String messageId , final Promise promise ) {
13871388 LogUtil .w (TAG , "resendMessage" + messageId );
1388- sessionService .resendMessage (messageId );
1389+ sessionService .queryMessage (messageId , new SessionService .OnMessageQueryListener () {
1390+ @ Override
1391+ public int onResult (int code , IMMessage message ) {
1392+ Map <String , Object > map = message .getLocalExtension ();
1393+ if (map != null ) {
1394+ if (map .containsKey ("resend" )) {
1395+ return -1 ;
1396+ }
1397+ }
1398+ promise .resolve ("200" );
1399+ sessionService .resendMessage (message );
1400+
1401+ return 0 ;
1402+ }
1403+ });
1404+
13891405 }
13901406
13911407 /**
@@ -1944,6 +1960,7 @@ public void onNewIntent(Intent intent) {
19441960 intent .putExtras (getIntent ());
19451961 reactContext .getCurrentActivity ().setIntent (intent );
19461962 ReactCache .emit (ReactCache .observeBackgroundPushEvent , ReceiverMsgParser .getWritableMap (intent ));
1963+ launch = null ;
19471964 }
19481965
19491966 }
@@ -1963,20 +1980,27 @@ public void getLaunch(Promise promise) {
19631980
19641981 @ Override
19651982 public void onHostResume () {
1966- if ( reactContext . getCurrentActivity () != null )
1967- LogUtil .w (TAG , reactContext . getCurrentActivity (). getClass (). getPackage (). getName () );
1968- LogUtil . w ( TAG , "onHostResume" );
1969-
1970- if (! TextUtils . isEmpty ( status )) {
1971- WritableMap r = Arguments .createMap ();
1972- r .putString ("status" , status );
1973- ReactCache .emit (ReactCache .observeOnKick , r );
1974- status = "" ;
1983+
1984+ LogUtil .w (TAG , "onHostResume:" + status );
1985+
1986+ if (! TextUtils . isEmpty ( status ) && ! "onHostPause" . equals ( status )) {
1987+ if (NIMClient . getStatus (). wontAutoLogin ( )) {
1988+ WritableMap r = Arguments .createMap ();
1989+ r .putString ("status" , status );
1990+ ReactCache .emit (ReactCache .observeOnKick , r );
1991+ }
19751992 }
1993+ // if (NIMClient.getStatus().wontAutoLogin()) {
1994+ // Toast.makeText(IMApplication.getContext(), "您的帐号已在别的设备登录,请重新登陆", Toast.LENGTH_SHORT).show();
1995+ // }
1996+ status = "" ;
19761997 }
19771998
19781999 @ Override
19792000 public void onHostPause () {
2001+ if (TextUtils .isEmpty (status )) {
2002+ status = "onHostPause" ;
2003+ }
19802004 LogUtil .w (TAG , "onHostPause" );
19812005 }
19822006
0 commit comments