最近我添加了Google Play Integrity。我已经将Google服务json文件添加到项目中,启用了Google云控制台上的API,并更新了移动的上的Google Play商店,但我仍然得到错误代码-1 [Integrity Api not found]
我的代码是
val nonce: String = generateNonce() //generated nonce at my side
// Create an instance of a manager.
val integrityManager: IntegrityManager = IntegrityManagerFactory.create(context.applicationContext)
// Request the integrity token by providing a nonce.
val integrityTokenResponse: Task<IntegrityTokenResponse> = integrityManager.requestIntegrityToken(
IntegrityTokenRequest.builder()
.setNonce(nonce)
.build())
integrityTokenResponse.addOnSuccessListener { response ->
val integrityToken: String = response.token()
println("integrityToken:="+integrityToken)
}
integrityTokenResponse.addOnFailureListener { e ->
println("integrityToken Error:="+e)
}
任何帮助都将不胜感激。
1条答案
按热度按时间rkkpypqq1#
我希望您已经解决了这个问题,但为了便于将来参考-如果您的应用正在运行,则必须在Google Play控制台中启用Play Integrity API。如果您的应用未在运行,则还应在请求中包含云项目编号:https://developer.android.com/reference/unity/class/Google/Play/Integrity/IntegrityTokenRequest#cloudprojectnumber。