इस गाइड में, Kotlin या Java का इस्तेमाल करके, ऐप्लिकेशन में समीक्षाएं पाने की सुविधा को इंटिग्रेट करने का तरीका बताया गया है. अगर नेटिव कोड, Unity या Unreal Engine का इस्तेमाल किया जा रहा है, तो इंटिग्रेशन की अलग-अलग गाइड उपलब्ध हैं.
अपना डेवलपमेंट एनवायरमेंट सेट अप करना
Play In-App Review Library, Google Play Core लाइब्रेरी का हिस्सा है. Play In-App Review Library को इंटिग्रेट करने के लिए, Gradle की यह डिपेंडेंसी शामिल करें.
Groovy
// In your app's build.gradle file: ... dependencies { // This dependency is downloaded from the Google's Maven repository. // So, make sure you also include that repository in your project's build.gradle file. implementation 'com.google.android.play:review:2.0.2' // For Kotlin users also add the Kotlin extensions library for Play In-App Review: implementation 'com.google.android.play:review-ktx:2.0.2' ... }
Kotlin
// In your app's build.gradle.kts file: ... dependencies { // This dependency is downloaded from the Google's Maven repository. // So, make sure you also include that repository in your project's build.gradle file. implementation("com.google.android.play:review:2.0.2") // For Kotlin users also import the Kotlin extensions library for Play In-App Review: implementation("com.google.android.play:review-ktx:2.0.2") ... }
ReviewManager बनाना
ReviewManager एक ऐसा इंटरफ़ेस है जो आपके ऐप्लिकेशन को, ऐप्लिकेशन में समीक्षा करने की सुविधा शुरू करने की अनुमति देता है. ReviewManagerFactory का इस्तेमाल करके इंस्टेंस बनाएं और इसे हासिल करें.
Kotlin
val manager = ReviewManagerFactory.create(context)
Java
ReviewManager manager = ReviewManagerFactory.create(context);
ReviewInfo ऑब्जेक्ट का अनुरोध करना
ऐप्लिकेशन में समीक्षाओं का अनुरोध कब करना है, इस बारे में दिए गए दिशा-निर्देशों का पालन करें. इससे आपको अपने ऐप्लिकेशन के यूज़र फ़्लो में सही समय पर उपयोगकर्ता से समीक्षा करने का अनुरोध करने में मदद मिलेगी. उदाहरण के लिए, जब उपयोगकर्ता किसी गेम में कोई लेवल पूरा कर लेता है. जब आपका ऐप्लिकेशन इनमें से किसी पॉइंट पर पहुंचता है, तो अनुरोध टास्क बनाने के लिए ReviewManager इंस्टेंस का इस्तेमाल करें. अगर अनुरोध पूरा हो जाता है, तो एपीआई ReviewInfo ऑब्जेक्ट दिखाता है. इसकी ज़रूरत, ऐप्लिकेशन में समीक्षा करने की सुविधा को शुरू करने के लिए होती है.
Kotlin
val request = manager.requestReviewFlow()
request.addOnCompleteListener { task ->
if (task.isSuccessful) {
// Got the ReviewInfo object
val reviewInfo = task.result
} else {
// There was some problem, log or handle the error code.
@ReviewErrorCode val reviewErrorCode = (task.getException() as ReviewException).errorCode
}
}
Java
ReviewManager manager = ReviewManagerFactory.create(this);
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(task -> {
if (task.isSuccessful()) {
// Get the ReviewInfo object
ReviewInfo reviewInfo = task.getResult();
} else {
// There was some problem, log or handle the error code.
@ReviewErrorCode int reviewErrorCode = ((ReviewException) task.getException()).getErrorCode();
}
});
ऐप्लिकेशन में समीक्षा करने की सुविधा लॉन्च करना
ऐप्लिकेशन में समीक्षा करने की सुविधा को लॉन्च करने के लिए, ReviewInfo इंस्टेंस का इस्तेमाल करें. जब तक उपयोगकर्ता, ऐप्लिकेशन में समीक्षा करने की प्रोसेस पूरी नहीं कर लेता, तब तक इंतज़ार करें. इसके बाद ही, आपका ऐप्लिकेशन सामान्य यूज़र फ़्लो (जैसे, अगले लेवल पर जाना) जारी रखेगा.
Kotlin
val flow = manager.launchReviewFlow(activity, reviewInfo)
flow.addOnCompleteListener { _ ->
// The flow has finished. The API doesn't indicate whether the user
// reviewed or not, or even whether the review dialog was shown. Thus, no
// matter the result, continue your app flow.
}
Java
Task<Void> flow = manager.launchReviewFlow(activity, reviewInfo);
flow.addOnCompleteListener(task -> {
// The flow has finished. The API doesn't indicate whether the user
// reviewed or not, or even whether the review dialog was shown. Thus, no
// matter the result, continue your app flow.
});
अगले चरण
अपने ऐप्लिकेशन में समीक्षा करने की सुविधा की जांच करें, ताकि यह पुष्टि की जा सके कि इंटिग्रेशन सही तरीके से काम कर रहा है.