توضّح هذه الصفحة كيفية التعامل مع المشاكل المتعلّقة بنتائج التحقّق من السلامة.
عند طلب رمز مميّز للسلامة، يمكنك اختيار عرض مربّع حوار Google Play للمستخدم. يمكنك عرض مربّع الحوار عندما تكون هناك مشكلة واحدة أو أكثر في نتيجة التحقّق من السلامة. يظهر مربّع الحوار أعلى تطبيقك، ويطلب من المستخدمين حلّ سبب المشكلة. بعد إغلاق مربّع الحوار، يمكنك التأكّد من حلّ المشكلة من خلال طلب آخر إلى Integrity API.
طلب ظهور مربّع حوار "توفير السلامة"
عندما يطلب العميل رمزًا مميّزًا للسلامة، يمكنك استخدام الطريقة المتوفّرة في StandardIntegrityToken (واجهة برمجة التطبيقات العادية) وIntegrityTokenResponse (واجهة برمجة التطبيقات الكلاسيكية):
showDialog(Activity activity, int integrityDialogTypeCode)
.
توضّح الخطوات التالية كيفية استخدام واجهة برمجة التطبيقات Play Integrity API لعرض مربّع حوار مخصَّص لتصدير البيانات الناقصة باستخدام رمز مربّع الحوار GET_LICENSED. يتم إدراج رموز مربّعات الحوار الأخرى التي يمكن أن يطلبها تطبيقك بعد هذا القسم.
اطلب رمزًا مميزًا للسلامة من تطبيقك، وأرسِل الرمز إلى خادمك. يمكنك استخدام الطلب "العادي" أو "الكلاسيكي".
Kotlin
// Request an integrity token val tokenResponse: StandardIntegrityToken = requestIntegrityToken() // Send token to app server and get response on what to do next val yourServerResponse: YourServerResponse = sendToServer(tokenResponse.token())
Java
// Request an integrity token StandardIntegrityToken tokenResponse = requestIntegrityToken(); // Send token to app server and get response on what to do next YourServerResponse yourServerResponse = sendToServer(tokenResponse.token());
Unity
// Request an integrity token StandardIntegrityToken tokenResponse = RequestIntegrityToken(); // Send token to app server and get response on what to do next YourServerResponse yourServerResponse = sendToServer(tokenResponse.Token);
Unreal Engine
// Request an integrity token StandardIntegrityToken* Response = RequestIntegrityToken(); // Send token to app server and get response on what to do next YourServerResponse YourServerResponse = SendToServer(Response->Token);
مدمجة مع المحتوى
/// Request an integrity token StandardIntegrityToken* response = requestIntegrityToken(); /// Send token to app server and get response on what to do next YourServerResponse yourServerResponse = sendToServer(StandardIntegrityToken_getToken(response));
على الخادم، فكِّر تشفير رمز التكامل وتحقَّق من الحقل
appLicensingVerdict
. قد يبدو على النحو التالي:// Licensing issue { ... accountDetails: { appLicensingVerdict: "UNLICENSED" } }
إذا كانت الرمز المميّز يتضمّن
appLicensingVerdict: "UNLICENSED"
، عليك الردّ على عميل تطبيقك بطلب عرض مربّع حوار الترخيص:Kotlin
private fun getDialogTypeCode(integrityToken: String): Int{ // Get licensing verdict from decrypted and verified integritytoken val licensingVerdict: String = getLicensingVerdictFromDecryptedToken(integrityToken) return if (licensingVerdict == "UNLICENSED") { 1 // GET_LICENSED } else 0 }
Java
private int getDialogTypeCode(String integrityToken) { // Get licensing verdict from decrypted and verified integrityToken String licensingVerdict = getLicensingVerdictFromDecryptedToken(integrityToken); if (licensingVerdict.equals("UNLICENSED")) { return 1; // GET_LICENSED } return 0; }
Unity
private int GetDialogTypeCode(string IntegrityToken) { // Get licensing verdict from decrypted and verified integrityToken string licensingVerdict = GetLicensingVerdictFromDecryptedToken(IntegrityToken); if (licensingVerdict == "UNLICENSED") { return 1; // GET_LICENSED } return 0; }
Unreal Engine
private int GetDialogTypeCode(FString IntegrityToken) { // Get licensing verdict from decrypted and verified integrityToken FString LicensingVerdict = GetLicensingVerdictFromDecryptedToken(IntegrityToken); if (LicensingVerdict == "UNLICENSED") { return 1; // GET_LICENSED } return 0; }
مدمجة مع المحتوى
private int getDialogTypeCode(string integrity_token) { /// Get licensing verdict from decrypted and verified integrityToken string licensing_verdict = getLicensingVerdictFromDecryptedToken(integrity_token); if (licensing_verdict == "UNLICENSED") { return 1; // GET_LICENSED } return 0; }
في تطبيقك، استدعِ الدالة
showDialog
باستخدام الرمز المطلوب الذي تم استرداده من الخادم:Kotlin
// Show dialog as indicated by the server val showDialogType: Int? = yourServerResponse.integrityDialogTypeCode() if (showDialogType != null) { // Call showDialog with type code, the dialog will be shown on top of the // provided activity and complete when the dialog is closed. val integrityDialogResponseCode: Task<Int> = tokenResponse.showDialog(activity, showDialogType) // Handle response code, call the Integrity API again to confirm that // verdicts have been resolved. }
Java
// Show dialog as indicated by the server @Nullable Integer showDialogType = yourServerResponse.integrityDialogTypeCode(); if (showDialogType != null) { // Call showDialog with type code, the dialog will be shown on top of the // provided activity and complete when the dialog is closed. Task<Integer> integrityDialogResponseCode = tokenResponse.showDialog(activity, showDialogType); // Handle response code, call the Integrity API again to confirm that // verdicts have been resolved. }
Unity
IEnumerator ShowDialogCoroutine() { int showDialogType = yourServerResponse.IntegrityDialogTypeCode(); // Call showDialog with type code, the dialog will be shown on top of the // provided activity and complete when the dialog is closed. var showDialogTask = tokenResponse.ShowDialog(showDialogType); // Wait for PlayAsyncOperation to complete. yield return showDialogTask; // Handle response code, call the Integrity API again to confirm that // verdicts have been resolved. }
Unreal Engine
// .h void MyClass::OnShowDialogCompleted( EStandardIntegrityErrorCode Error, EIntegrityDialogResponseCode Response) { // Handle response code, call the Integrity API again to confirm that // verdicts have been resolved. } // .cpp void MyClass::RequestIntegrityToken() { UStandardIntegrityToken* Response = ... int TypeCode = YourServerResponse.integrityDialogTypeCode(); // Create a delegate to bind the callback function. FShowDialogStandardOperationCompletedDelegate Delegate; // Bind the completion handler (OnShowDialogCompleted) to the delegate. Delegate.BindDynamic(this, &MyClass::OnShowDialogCompleted); // Call ShowDialog with TypeCode which completes when the dialog is closed. Response->ShowDialog(TypeCode, Delegate); }
مدمجة مع المحتوى
// Show dialog as indicated by the server int show_dialog_type = yourServerResponse.integrityDialogTypeCode(); if (show_dialog_type != 0) { /// Call showDialog with type code, the dialog will be shown on top of the /// provided activity and complete when the dialog is closed. StandardIntegrityErrorCode error_code = IntegrityTokenResponse_showDialog(response, activity, show_dialog_type); /// Proceed to polling iff error_code == STANDARD_INTEGRITY_NO_ERROR if (error_code != STANDARD_INTEGRITY_NO_ERROR) { /// Remember to call the *_destroy() functions. return; } /// Use polling to wait for the async operation to complete. /// Note, the polling shouldn't block the thread where the IntegrityManager /// is running. IntegrityDialogResponseCode* response_code; error_code = StandardIntegrityToken_getDialogResponseCode(response, response_code); if (error_code != STANDARD_INTEGRITY_NO_ERROR) { /// Remember to call the *_destroy() functions. return; } /// Handle response code, call the Integrity API again to confirm that /// verdicts have been resolved. }
يتم عرض مربّع الحوار أعلى النشاط المقدَّم. عندما يغلق المستخدم مربّع الحوار، تكتمل المهمة مع رمز استجابة.
(اختياري) اطلب رمزًا مميّزًا آخر لعرض أي مربّعات حوار أخرى. في حال تقديم طلبات عادية، عليك إعادة تحضير مقدّم الرموز المميزة للحصول على نتيجة جديدة.
رموز مربّع حوار التحقّق من السلامة
GET_LICENSED (رمز النوع 1)
مشكلة متعلّقة بالقرار
مربّع الحوار هذا مناسب لحالتَين:
- الوصول غير المصرَّح به:
appLicensingVerdict: "UNLICENSED"
وهذا يعني أنّ حساب المستخدم ليس لديه إذن الوصول إلى تطبيقك، وهو ما يحدث إذا ثبَّت المستخدم التطبيق من مصدر غير معروف أو حصل عليه من متجر تطبيقات آخر غير Google Play. - تطبيق تم التلاعب به:
appRecognitionVerdict: "UNRECOGNIZED_VERSION"
. وهذا يعني أنّه تم تعديل البرنامج الثنائي لتطبيقك أو أنّه ليس إصدارًا يتعرّف عليه Google Play.
المعالجة
يمكنك عرض مربّع الحوار GET_LICENSED
لتطلب من المستخدم الحصول على التطبيق الأصلي من Google Play. يتناول مربّع الحوار الفردي هذا كلا السيناريوهَين:
- بالنسبة إلى المستخدم غير المرخَّص، يمنحه ترخيص Play. ويتيح ذلك للمستخدم تلقّي تحديثات التطبيقات من Google Play.
- بالنسبة إلى المستخدم الذي لديه إصدار معدَّل من التطبيق، يتم توجيهه إلى تثبيت الإصدار غير المعدَّل من التطبيق من Google Play.
عندما يُكمل المستخدم مربّع الحوار، تعرض عمليات التحقّق اللاحقة من السلامة الرمزين appLicensingVerdict: "LICENSED"
وappRecognitionVerdict: "PLAY_RECOGNIZED"
.
مثال على تجربة المستخدم

CLOSE_UNKNOWN_ACCESS_RISK (رمز النوع 2)
مشكلة متعلّقة بالقرار
عندما يحتوي environmentDetails.appAccessRiskVerdict.appsDetected
على "UNKNOWN_CAPTURING"
أو "UNKNOWN_CONTROLLING"
، يعني ذلك أنّ هناك تطبيقات غير معروفة تعمل على الجهاز ويمكنها أخذ لقطات للشاشة أو التحكّم في الجهاز.
المعالجة
يمكنك عرض مربّع الحوار CLOSE_UNKNOWN_ACCESS_RISK
لتنبيه المستخدم إلى إغلاق جميع التطبيقات غير المعروفة التي قد تسجّل الشاشة أو تتحكّم في الجهاز.
إذا نقر المستخدم على الزر Close all
، سيتم إغلاق جميع هذه التطبيقات.
مثال على تجربة المستخدم

CLOSE_ALL_ACCESS_RISK (رمز النوع 3)
مشكلة متعلّقة بالقرار
عندما تتضمّن environmentDetails.appAccessRiskVerdict.appsDetected
أيًا من "KNOWN_CAPTURING"
أو "KNOWN_CONTROLLING"
أو "UNKNOWN_CAPTURING"
أو "UNKNOWN_CONTROLLING"
، يعني ذلك أنّ هناك تطبيقات قيد التشغيل على الجهاز يمكنها أخذ لقطات للشاشة أو التحكم في الجهاز.
المعالجة
يمكنك عرض مربّع الحوار CLOSE_ALL_ACCESS_RISK
لطلب إغلاق جميع التطبيقات التي يمكنها أخذ لقطات للشاشة أو التحكّم في الجهاز. إذا نقر المستخدم على الزر Close all
، سيتم إغلاق جميع هذه التطبيقات على الجهاز.
مثال على تجربة المستخدم
