优化google登陆流程
This commit is contained in:
parent
80fc141ce0
commit
8f1001d240
@ -69,7 +69,7 @@ bool AppDelegate::applicationDidFinishLaunching()
|
||||
jsb_run_script("js/jcwallet.js");
|
||||
jsb_run_script("js/platform.js");
|
||||
jsb_run_script("js/main.js");
|
||||
|
||||
Application::getInstance()->setKeyMaster("1111");
|
||||
se->addAfterCleanupHook([]() {
|
||||
JSBClassType::destroy();
|
||||
});
|
||||
|
@ -7,12 +7,11 @@ android {
|
||||
buildToolsVersion PROP_BUILD_TOOLS_VERSION
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.fitchgc.headlesscocos"
|
||||
applicationId "com.fitchgc.jcwallet"
|
||||
minSdkVersion PROP_MIN_SDK_VERSION
|
||||
targetSdkVersion PROP_TARGET_SDK_VERSION
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
ndk{
|
||||
abiFilters 'armeabi-v7a','arm64-v8a', 'x86'
|
||||
}
|
||||
@ -41,7 +40,7 @@ android {
|
||||
}
|
||||
|
||||
manifestPlaceholders = [
|
||||
'appAuthRedirectScheme': 'com.googleusercontent.apps.165555585193-ud80sst45po348ohec2h33t2m6mjnlt0'
|
||||
'appAuthRedirectScheme': 'com.googleusercontent.apps.165555585193-glmtnb94s3kkq906hal72ppiuoqpjjc5'
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -120,6 +120,7 @@ public class MainActivity extends Activity
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
super.onCreate(savedInstanceState);
|
||||
Log.i(TAG, "onCreate: " + getIntent().getDataString());
|
||||
|
||||
String cmdLine = updateUnityCommandLineArguments(getIntent().getStringExtra("unity"));
|
||||
getIntent().putExtra("unity", cmdLine);
|
||||
@ -127,8 +128,7 @@ public class MainActivity extends Activity
|
||||
mUnityPlayer = new UnityPlayer(this);
|
||||
setContentView(mUnityPlayer);
|
||||
mUnityPlayer.requestFocus();
|
||||
|
||||
// setContentView(R.layout.activity_main);
|
||||
|
||||
onLoadNativeLibraries();
|
||||
app = this;
|
||||
Cocos2dxHelper.init(this);
|
||||
@ -188,7 +188,7 @@ public class MainActivity extends Activity
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
JcSDK.csCallback(funId, "{errcode: 0, errmsg: 'cancel'}");
|
||||
// JcSDK.csCallback(funId, "{errcode: 0, errmsg: 'cancel'}");
|
||||
funId = "";
|
||||
}
|
||||
}
|
||||
@ -411,6 +411,7 @@ public class MainActivity extends Activity
|
||||
// end of qrcode
|
||||
|
||||
public void signWithGoogle(String funId) {
|
||||
this.funId = funId;
|
||||
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(this) == ConnectionResult.SUCCESS) {
|
||||
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(this);
|
||||
if (account != null) {
|
||||
@ -423,7 +424,17 @@ public class MainActivity extends Activity
|
||||
Log.i(TAG, "no gms, use app auth");
|
||||
AuthState state = mAuthStateManager.getCurrent();
|
||||
if (state.isAuthorized() && state.getIdToken() != null) {
|
||||
Log.w(TAG, "already login: " + state.getIdToken());
|
||||
Log.w(TAG, "getNeedsTokenRefresh: " + state.getNeedsTokenRefresh());
|
||||
if (state.getNeedsTokenRefresh()) {
|
||||
Log.w(TAG, "need refresh accessToken");
|
||||
TokenRequest tokenRequest = state.createTokenRefreshRequest();
|
||||
performTokenRequest(
|
||||
tokenRequest,
|
||||
this::handleCodeExchangeResponse);
|
||||
} else {
|
||||
Log.w(TAG, "already login, accessToken not expired");
|
||||
Log.w(TAG, "id token : " + state.getIdToken());
|
||||
}
|
||||
} else {
|
||||
mExecutor.submit(this::doAuth);
|
||||
}
|
||||
@ -441,7 +452,7 @@ public class MainActivity extends Activity
|
||||
try {
|
||||
GoogleSignInAccount account = completedTask.getResult(ApiException.class);
|
||||
Log.w(TAG, "signIn success: ");
|
||||
Log.w(TAG, "idToken: " + account.getIdToken());
|
||||
Log.w(TAG, "app auth idToken: " + account.getIdToken());
|
||||
// Signed in successfully, show authenticated UI.
|
||||
} catch (ApiException e) {
|
||||
// The ApiException status code indicates the detailed failure reason.
|
||||
@ -693,10 +704,9 @@ public class MainActivity extends Activity
|
||||
//noinspection WrongThread
|
||||
Log.d(TAG, message);
|
||||
} else {
|
||||
Log.d(TAG, "success");
|
||||
AuthState state = mAuthStateManager.getCurrent();
|
||||
Log.d(TAG, String.valueOf(state.isAuthorized()));
|
||||
Log.d(TAG, String.valueOf(state.getIdToken()));
|
||||
Log.d(TAG, "login success, auth state: " + state.isAuthorized());
|
||||
Log.d(TAG, "app auth idToken: " + state.getIdToken());
|
||||
mAuthStateManager.replace(state);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user