[英]Play Games Sign in does not work after publishing it in play store but it was working when i tested on my android device from android studio
Play games sign in is not working in my app after i published it.在我发布应用后,玩游戏登录在我的应用中不起作用。 I am unable to understant what is the problem These are the functions created for signingin and for achievements and leaderboard.I think problem is related to OAuth Server but i dont know how to do it.Can Somone Explain it.我无法理解问题是什么这些是为登录、成就和排行榜创建的功能。我认为问题与 OAuth 服务器有关,但我不知道该怎么做。Somone 可以解释一下吗?
private fun startSignInIntent() {
val signInClient = GoogleSignIn.getClient(this,
GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
val intent = signInClient.signInIntent
startActivityForResult(intent, RC_SIGN_IN)
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == RC_SIGN_IN) {
val result = Auth.GoogleSignInApi.getSignInResultFromIntent(data)
if (result!!.isSuccess) {
mServerAuthCode = result.signInAccount!!.serverAuthCode
// The signed in account is stored in the result.
val signedInAccount = result.signInAccount
} else {
var message = result.status.statusMessage
if (message == null || message.isEmpty()) {
message = getString(R.string.signin_other_error)
}
AlertDialog.Builder(this).setMessage(message)
.setNeutralButton(android.R.string.ok, null).show()
}
}
}
private fun showAchievements() {
Games.getAchievementsClient(this, GoogleSignIn.getLastSignedInAccount(this)!!)
.achievementsIntent
.addOnSuccessListener { intent -> startActivityForResult(intent, RC_ACHIEVEMENT_UI) }
}
private val RC_LEADERBOARD_UI = 9004
private fun showLeaderboard() {
Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this)!!)
.getLeaderboardIntent(getString(R.string.leaderboard_marathon))
.addOnSuccessListener { intent -> startActivityForResult(intent, RC_LEADERBOARD_UI) }
}
private fun showLeaderboard2() {
Games.getLeaderboardsClient(this, GoogleSignIn.getLastSignedInAccount(this)!!)
.getLeaderboardIntent(getString(R.string.leaderboard_timer_mode))
.addOnSuccessListener { intent -> startActivityForResult(intent, RC_LEADERBOARD_UI) }
}
private fun signOut() {
val signInClient = GoogleSignIn.getClient(this,
GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
signInClient.signOut().addOnCompleteListener(this
) {
// at this point, the user is signed out.
}
}
private fun signInSilently() {
val signInOptions = GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN
val account = GoogleSignIn.getLastSignedInAccount(this)
if (GoogleSignIn.hasPermissions(account, *signInOptions.scopeArray)) {
// Already signed in.
// The signed in account is stored in the 'account' variable.
val signedInAccount = account
} else {
// Haven't been signed-in before. Try the silent sign-in first.
val signInClient = GoogleSignIn.getClient(this, signInOptions)
signInClient
.silentSignIn()
.addOnCompleteListener(
this
) { task ->
if (task.isSuccessful) {
val signedInAccount = task.result
}
}
}
After you publish the app on Play Store, Google signs it and the Google app signing key certificate needs to be registered in the project's Firebase console for it to work.在 Play Store 上发布应用程序后,谷歌对其进行签名,并且需要在项目的 Firebase 控制台中注册谷歌应用程序签名密钥证书才能运行。 After you publish the app, in the Play Console, under Release, click on Settings.发布应用后,在 Play 管理中心的发布下,点击设置。 Click on App Integrity.单击应用程序完整性。 Click on the App Signing tab.单击“应用程序签名”选项卡。 Copy the SHA-1 fingerprint to your clipboard.将 SHA-1 指纹复制到剪贴板。 Go to your Firebase Console and select your project. Go 到您的 Firebase 控制台和 select 您的项目。 To the right of Project Overview, click the gear icon and select Project Settings.在项目概览的右侧,单击齿轮图标和 select 项目设置。 Under Your Apps, click on your Android app and enter the SHA-1 fingerprint that you copied from the App Signing tab.在您的应用程序下,单击您的 Android 应用程序并输入您从应用程序签名选项卡复制的 SHA-1 指纹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.