توضّح هذه الصفحة كيفية التعامل مع المشاكل المتعلّقة بنتائج سلامة التطبيق.
عند طلب رمز أمان، يمكنك عرض مربّع حوار 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.
المعالجة
يمكنك عرض مربّع الحوار GET_LICENSED
لطلب تثبيت تطبيقك من
Google Play. وفي حال قبول المستخدم، يصبح حساب المستخدم مرخّصًا
(appLicensingVerdict == "LICENSED"
). تتم إضافة التطبيق إلى مكتبة Google
Play الخاصة بالمستخدم ويمكن أن يقدّم Google Play تحديثات التطبيق نيابةً عنك.
مثال على تجربة المستخدم
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
، سيتم إغلاق جميع هذه التطبيقات على الجهاز.