دمج المراجعات داخل التطبيق (Unity)
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يوضّح هذا الدليل كيفية دمج المراجعات داخل التطبيق باستخدام Unity.
تتوفّر أدلة دمج منفصلة في حال كنت تستخدم Kotlin أو Java أو
الرمز الأصلي أو Unreal Engine.
نظرة عامة على حزمة تطوير البرامج (SDK) في Unity
تشكّل واجهة برمجة التطبيقات Play In-App Review API جزءًا من عائلة حزمة تطوير البرامج (SDK) Play Core. توفّر واجهة برمجة التطبيقات لIDE
Unity فئة ReviewManager
لطلب عملية الربط وإطلاقها باستخدام methods
RequestReviewFlow
وLaunchReviewFlow
. بعد تقديم
طلب، يمكن لتطبيقك التحقّق من حالة الطلب باستخدام
ReviewErrorCode
.
إعداد بيئة التطوير
OpenUPM-CLI
إذا كان لديك واجهة برمجة التطبيقات OpenUPM
مثبّتة، يمكنك تثبيت قاعدة بيانات مسجّلي OpenUPM باستخدام الأمر التالي:
openupm add com.google.play.review
OpenUPM
افتح إعدادات مدير الحِزم
من خلال اختيار خيار قائمة Unity
تعديل > إعدادات المشروع > مدير الحِزم.
أضِف OpenUPM كقاعدة بيانات مسجّلين على مستوى النطاق إلى نافذة "مدير الحِزم":
Name: package.openupm.com
URL: https://package.openupm.com
Scopes: com.google.external-dependency-manager
com.google.play.common
com.google.play.core
com.google.play.review
افتح قائمة مدير الحِزم من خلال اختيار خيار قائمة Unity
نافذة > مدير الحِزم.
اضبط القائمة المنسدلة لنطاق عمل المدير لاختيار سجلّاتي.
اختَر حزمة Google Play Integrity plugin for Unity من قائمة الحِزم واضغط على تثبيت.
الاستيراد من GitHub
نزِّل أحدث إصدار من .unitypackage
من GitHub.
استورِد ملف .unitypackage
من خلال اختيار خيار قائمة Unity التالي:
مواد العرض > استيراد حزمة > حزمة مخصّصة واستيراد جميع العناصر.
إنشاء ReviewManager
أنشئ مثيلًا من ReviewManager
يعالج الاتصالات بين
تطبيقك وGoogle Play API.
using Google.Play.Review;
// Create instance of ReviewManager
private ReviewManager _reviewManager;
// ...
_reviewManager = new ReviewManager();
طلب عنصر ReviewInfo
اتّبِع الإرشادات حول حالات طلب إجراء مراجعات داخل التطبيق لتحديد نقاط جيدة في مسار المستخدِم في تطبيقك لطلب إجراء مراجعة (على سبيل المثال،
بعد أن يغلِق المستخدِم شاشة الملخّص في نهاية مستوى في لعبة). عندما يقترب تطبيقك من إحدى هذه النقاط، استخدِم مثيل ReviewManager
لإنشاء عملية غير متزامنة، كما هو موضّح في المثال التالي:
var requestFlowOperation = _reviewManager.RequestReviewFlow();
yield return requestFlowOperation;
if (requestFlowOperation.Error != ReviewErrorCode.NoError)
{
// Log error. For example, using requestFlowOperation.Error.ToString().
yield break;
}
_playReviewInfo = requestFlowOperation.GetResult();
إذا كان الطلب ناجحًا، ستُرجع واجهة برمجة التطبيقات العنصر PlayReviewInfo
الذي يحتاجه تطبيقك لبدء عملية المراجعة داخل التطبيق. في المثال، يتم إجراء المكالمة
داخل متغيّر استدعاء منتظم
لتنفيذ العملية غير المتزامنة (لا يؤدي ذلك إلى حظر سلسلة التعليمات الرئيسية). ولأنّه يتم إجراء المكالمة بشكل غير متزامن، قد يستغرق الأمر بضع ثوانٍ، لذا يجب أن يجري تطبيقك المكالمة قبل أن يصل إلى النقطة في مسار المستخدِم التي تريد فيها عرض المراجعة داخل التطبيق.
بدء عملية المراجعة داخل التطبيق
بعد أن يتلقّى تطبيقك مثيل PlayReviewInfo
، يمكنه بدء عملية
المراجعة داخل التطبيق. يُرجى العلم أنّ عنصر PlayReviewInfo
صالح فقط لفترة محدودة، لذا يجب ألا ينتظر تطبيقك وقتًا طويلاً قبل بدء مسار.
var launchFlowOperation = _reviewManager.LaunchReviewFlow(_playReviewInfo);
yield return launchFlowOperation;
_playReviewInfo = null; // Reset the object
if (launchFlowOperation.Error != ReviewErrorCode.NoError)
{
// Log error. For example, using launchFlowOperation.Error.ToString().
yield break;
}
// The flow has finished. The API does not indicate whether the user
// reviewed or not, or even whether the review dialog was shown. Thus, no
// matter the result, we continue our app flow.
الخطوات التالية
اختبِر مسار المراجعة داخل تطبيقك للتأكّد من أنّ عملية الدمج تعمل بشكلٍ سليم.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Integrate in-app reviews (Unity)\n\nThis guide describes how to integrate in-app reviews in your app using Unity.\nThere are separate integration guides for if you are using [Kotlin or Java](/guide/playcore/in-app-review/kotlin-java),\n[native code](/guide/playcore/in-app-review/native) or [Unreal Engine](/guide/playcore/in-app-review/unreal-engine).\n\nUnity SDK overview\n------------------\n\nThe Play In-App Review API is part of [Play Core SDK](/reference/com/google/android/play/core/release-notes) family. The API for\nUnity offers a [`ReviewManager`](/reference/unity/class/Google/Play/Review/ReviewManager) class to request and launch the flow using\nthe [`RequestReviewFlow`](/reference/unity/class/Google/Play/Review/ReviewManager#requestreviewflow) and [`LaunchReviewFlow`](/reference/unity/class/Google/Play/Review/ReviewManager#launchreviewflow) methods. After a\nrequest is made, your app can check the status of the request using\n[`ReviewErrorCode`](/reference/unity/namespace/Google/Play/Review#reviewerrorcode).\n\nSet up your development environment\n-----------------------------------\n\n### OpenUPM-CLI\n\nIf you have the [OpenUPM CLI](https://github.com/openupm/openupm-cli#installation)\ninstalled you can install the OpenUPM registry with the following command: \n\n openupm add com.google.play.review\n\n### OpenUPM\n\n1. Open the [package manager settings](https://docs.unity3d.com/Manual/class-PackageManager.html)\n by selecting the Unity menu option\n **Edit \\\u003e Project Settings \\\u003e Package Manager**.\n\n2. Add OpenUPM as a scoped registry to the Package Manager window:\n\n Name: package.openupm.com\n URL: https://package.openupm.com\n Scopes: com.google.external-dependency-manager\n com.google.play.common\n com.google.play.core\n com.google.play.review\n\n3. Open the [package manager menu](//docs.unity3d.com/Manual/upm-ui-install.html) by selecting the Unity\n menu option **Window \\\u003e Package Manager**.\n\n4. Set the manager scope drop-down to select **My Registries**.\n\n5. Select the **Google Play Integrity plugin for Unity** package from the\n package list and press **Install**.\n\n### Import from GitHub\n\n1. Download the latest [`.unitypackage`](//github.com/google/play-in-app-reviews-unity/releases/latest)\n release from GitHub.\n\n2. Import the `.unitypackage` file by selecting the Unity menu option\n **Assets \\\u003e Import package \\\u003e Custom Package** and importing all items.\n\n| **Note:** By downloading and using Google Play Unity Plugins, you agree to the [Play Core Software Development Kit Terms of Service](/guide/playcore#license).\n\nCreate the ReviewManager\n------------------------\n\nCreate an instance of [`ReviewManager`](/reference/unity/class/Google/Play/Review/ReviewManager) that handles communication between\nyour app and the Google Play API. \n\n using Google.Play.Review;\n\n // Create instance of ReviewManager\n private ReviewManager _reviewManager;\n // ...\n _reviewManager = new ReviewManager();\n\nRequest a ReviewInfo object\n---------------------------\n\nFollow the guidance about [when to request in-app reviews](/guide/playcore/in-app-review#when-to-request) to determine good\npoints in your app's user flow to prompt the user for a review (for example,\nafter a user dismisses the summary screen at the end of a level in a game). When\nyour app gets close one of these points, use the [`ReviewManager`](/reference/unity/class/Google/Play/Review/ReviewManager) instance\nto create an async operation, as shown in the following example: \n\n var requestFlowOperation = _reviewManager.RequestReviewFlow();\n yield return requestFlowOperation;\n if (requestFlowOperation.Error != ReviewErrorCode.NoError)\n {\n // Log error. For example, using requestFlowOperation.Error.ToString().\n yield break;\n }\n _playReviewInfo = requestFlowOperation.GetResult();\n\nIf the call is successful, the API returns the [`PlayReviewInfo`](/reference/unity/class/Google/Play/Review/PlayReviewInfo) object\nthat your app needs to launch the in-app review flow. In the example, the call\nis made inside a [coroutine](https://docs.unity3d.com/Manual/Coroutines.html)\nto perform the async operation (this does not block the Main thread). Because\nthe call is made asynchronously, it might take up to a couple of seconds, so\nyour app should make the call before your app reaches the point in your user\nflow where you want to show the in-app review.\n\nLaunch the in-app review flow\n-----------------------------\n\nAfter your app receives the [`PlayReviewInfo`](/reference/unity/class/Google/Play/Review/PlayReviewInfo) instance, it can launch the\nin-app review flow. Note that the `PlayReviewInfo` object is only valid for a\nlimited amount of time, so your app should not wait too long before launching a\nflow. \n\n var launchFlowOperation = _reviewManager.LaunchReviewFlow(_playReviewInfo);\n yield return launchFlowOperation;\n _playReviewInfo = null; // Reset the object\n if (launchFlowOperation.Error != ReviewErrorCode.NoError)\n {\n // Log error. For example, using launchFlowOperation.Error.ToString().\n yield break;\n }\n // The flow has finished. The API does not indicate whether the user\n // reviewed or not, or even whether the review dialog was shown. Thus, no\n // matter the result, we continue our app flow.\n\nNext steps\n----------\n\n[Test your app's in-app review flow](/guide/playcore/in-app-review/test) to verify that your integration is\nworking correctly."]]