@@ -715,7 +715,7 @@ private File getOutputMediaFile(String ext){
715
715
*
716
716
* @param jsonObject
717
717
*/
718
- public static void initOpenidAndToken (JSONObject jsonObject ) {
718
+ public static boolean initOpenidAndToken (JSONObject jsonObject ) {
719
719
try {
720
720
String token = jsonObject .getString (Constants .PARAM_ACCESS_TOKEN );
721
721
String expires = jsonObject .getString (Constants .PARAM_EXPIRES_IN );
@@ -724,9 +724,11 @@ public static void initOpenidAndToken(JSONObject jsonObject) {
724
724
&& !TextUtils .isEmpty (openId )) {
725
725
mTencent .setAccessToken (token , expires );
726
726
mTencent .setOpenId (openId );
727
+ return true ;
727
728
}
728
729
} catch (Exception e ) {
729
730
}
731
+ return false ;
730
732
}
731
733
732
734
/**
@@ -740,17 +742,19 @@ public void onComplete(Object response) {
740
742
return ;
741
743
}
742
744
JSONObject jsonResponse = (JSONObject ) response ;
743
- if (null != jsonResponse && jsonResponse .length () == 0 ) {
745
+ if (jsonResponse .length () == 0 ) {
744
746
mPromise .reject ("600" ,QQ_RESPONSE_ERROR );
745
747
return ;
746
748
}
747
- initOpenidAndToken (jsonResponse );
748
- WritableMap map = Arguments .createMap ();
749
- map .putString ("userid" , mTencent .getOpenId ());
750
- map .putString ("access_token" , mTencent .getAccessToken ());
751
- map .putDouble ("expires_time" , mTencent .getExpiresIn ());
752
- mPromise .resolve (map );
753
-
749
+ if (initOpenidAndToken (jsonResponse )) {
750
+ WritableMap map = Arguments .createMap ();
751
+ map .putString ("userid" , mTencent .getOpenId ());
752
+ map .putString ("access_token" , mTencent .getAccessToken ());
753
+ map .putDouble ("expires_time" , mTencent .getExpiresIn ());
754
+ mPromise .resolve (map );
755
+ } else {
756
+ mPromise .reject ("600" ,QQ_RESPONSE_ERROR );
757
+ }
754
758
}
755
759
756
760
@ Override
0 commit comments