इस गाइड में, नेटिव (C या C++) कोड का इस्तेमाल करके, अपने ऐप्लिकेशन में इन-ऐप्लिकेशन समीक्षाओं को इंटिग्रेट करने का तरीका बताया गया है. अगर Kotlin या Java, Unity या Unreal Engine का इस्तेमाल किया जा रहा है, तो इंटिग्रेशन के लिए अलग-अलग गाइड उपलब्ध हैं.
नेटिव एसडीके के बारे में खास जानकारी
Play Core Native SDK, Google Play Core libraries फ़ैमिली का हिस्सा है. Play Core Native SDK में एक C हेडर फ़ाइल, review.h
शामिल होती है. यह Java Play In-App Review लाइब्रेरी से ReviewManager
को रैप करती है. इस हेडर फ़ाइल की मदद से, आपका ऐप्लिकेशन सीधे तौर पर एपीआई को कॉल कर सकता है. उपलब्ध सार्वजनिक फ़ंक्शन की खास जानकारी के लिए, Play की समीक्षा करने वाले नेटिव मॉड्यूल का दस्तावेज़ देखें.
ReviewManager_requestReviewFlow
एक ऐसा अनुरोध शुरू करता है जो बाद में ऐप्लिकेशन में समीक्षा करने की सुविधा लॉन्च करने के लिए ज़रूरी जानकारी इकट्ठा करता है. ReviewManager_getReviewStatus
का इस्तेमाल करके, अनुरोध के नतीजे को ट्रैक किया जा सकता है. ReviewManager_getReviewStatus
से मिलने वाले सभी स्टेटस के बारे में ज़्यादा जानने के लिए, ReviewErrorCode
देखें.
अनुरोध और लॉन्च, दोनों फ़ंक्शन के सफल होने पर REVIEW_NO_ERROR
दिखता है.
डेवलपमेंट एनवायरमेंट सेट अप करना
डाउनलोड करें Play Core Native SDK
डाउनलोड करने से पहले, आपको नीचे दी गई शर्तों को स्वीकार करना होगा.
नियम और शर्तें
Last modified: September 24, 2020- By using the Play Core Software Development Kit, you agree to these terms in addition to the Google APIs Terms of Service ("API ToS"). If these terms are ever in conflict, these terms will take precedence over the API ToS. Please read these terms and the API ToS carefully.
- For purposes of these terms, "APIs" means Google's APIs, other developer services, and associated software, including any Redistributable Code.
- “Redistributable Code” means Google-provided object code or header files that call the APIs.
- Subject to these terms and the terms of the API ToS, you may copy and distribute Redistributable Code solely for inclusion as part of your API Client. Google and its licensors own all right, title and interest, including any and all intellectual property and other proprietary rights, in and to Redistributable Code. You will not modify, translate, or create derivative works of Redistributable Code.
- Google may make changes to these terms at any time with notice and the opportunity to decline further use of the Play Core Software Development Kit. Google will post notice of modifications to the terms at https://developer.android.com/guide/playcore/license. Changes will not be retroactive.
इनमें से कोई एक काम करें:
- Android Studio का 4.0 या इसके बाद का वर्शन इंस्टॉल करें. Android SDK Platform के 10.0 वर्शन (एपीआई लेवल 29) को इंस्टॉल करने के लिए, SDK Manager यूज़र इंटरफ़ेस (यूआई) का इस्तेमाल करें.
- Android SDK कमांड-लाइन टूल इंस्टॉल करें
और Android SDK प्लैटफ़ॉर्म के 10.0 वर्शन (एपीआई लेवल 29) को इंस्टॉल करने के लिए,
sdkmanager
का इस्तेमाल करें.
Android Studio को नेटिव डेवलपमेंट के लिए तैयार करें. इसके लिए, एसडीके मैनेजर का इस्तेमाल करके, CMake और Android नेटिव डेवलपमेंट किट (NDK) का नया वर्शन इंस्टॉल करें. नेटिव प्रोजेक्ट बनाने या इंपोर्ट करने के बारे में ज़्यादा जानने के लिए, NDK का इस्तेमाल शुरू करना लेख पढ़ें.
ज़िप फ़ाइल डाउनलोड करें और उसे अपने प्रोजेक्ट के साथ एक्स्ट्रैक्ट करें.
डाउनलोड करने का लिंक साइज़ SHA-256 चेकसम 39.6 MiB 92b43246860d4ce4772a3a0786212d9b4781920e112d81b93ca1c5ebd8da89cb अपने ऐप्लिकेशन की
build.gradle
फ़ाइल को यहां दिए गए तरीके से अपडेट करें:ग्रूवी
// App build.gradle plugins { id 'com.android.application' } // Define a path to the extracted Play Core SDK files. // If using a relative path, wrap it with file() since CMake requires absolute paths. def playcoreDir = file('../path/to/playcore-native-sdk') android { defaultConfig { ... externalNativeBuild { cmake { // Define the PLAYCORE_LOCATION directive. arguments "-DANDROID_STL=c++_static", "-DPLAYCORE_LOCATION=$playcoreDir" } } ndk { // Skip deprecated ABIs. Only required when using NDK 16 or earlier. abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' } } buildTypes { release { // Include Play Core Library proguard config files to strip unused code while retaining the Java symbols needed for JNI. proguardFile '$playcoreDir/proguard/common.pgcfg' proguardFile '$playcoreDir/proguard/gms_task.pgcfg' proguardFile '$playcoreDir/proguard/per-feature-proguard-files' ... } debug { ... } } externalNativeBuild { cmake { path 'src/main/CMakeLists.txt' } } } dependencies { // Import these feature-specific AARs for each Google Play Core library. implementation 'com.google.android.play:app-update:2.1.0' implementation 'com.google.android.play:asset-delivery:2.3.0' implementation 'com.google.android.play:integrity:1.4.0' implementation 'com.google.android.play:review:2.0.2' // Import these common dependencies. implementation 'com.google.android.gms:play-services-tasks:18.0.2' implementation files("$playcoreDir/playcore-native-metadata.jar") ... }
Kotlin
// App build.gradle plugins { id("com.android.application") } // Define a path to the extracted Play Core SDK files. // If using a relative path, wrap it with file() since CMake requires absolute paths. val playcoreDir = file("../path/to/playcore-native-sdk") android { defaultConfig { ... externalNativeBuild { cmake { // Define the PLAYCORE_LOCATION directive. arguments += listOf("-DANDROID_STL=c++_static", "-DPLAYCORE_LOCATION=$playcoreDir") } } ndk { // Skip deprecated ABIs. Only required when using NDK 16 or earlier. abiFilters.clear() abiFilters += listOf("armeabi-v7a", "arm64-v8a", "x86", "x86_64") } } buildTypes { release { // Include Play Core Library proguard config files to strip unused code while retaining the Java symbols needed for JNI. proguardFile("$playcoreDir/proguard/common.pgcfg") proguardFile("$playcoreDir/proguard/gms_task.pgcfg") proguardFile("$playcoreDir/proguard/per-feature-proguard-files") ... } debug { ... } } externalNativeBuild { cmake { path = "src/main/CMakeLists.txt" } } } dependencies { // Import these feature-specific AARs for each Google Play Core library. implementation("com.google.android.play:app-update:2.1.0") implementation("com.google.android.play:asset-delivery:2.3.0") implementation("com.google.android.play:integrity:1.4.0") implementation("com.google.android.play:review:2.0.2") // Import these common dependencies. implementation("com.google.android.gms:play-services-tasks:18.0.2") implementation(files("$playcoreDir/playcore-native-metadata.jar")) ... }
अपने ऐप्लिकेशन की
CMakeLists.txt
फ़ाइलों को यहां दिए गए तरीके से अपडेट करें:cmake_minimum_required(VERSION 3.6) ... # Add a static library called “playcore” built with the c++_static STL. include(${PLAYCORE_LOCATION}/playcore.cmake) add_playcore_static_library() // In this example “main” is your native code library, i.e. libmain.so. add_library(main SHARED ...) target_include_directories(main PRIVATE ${PLAYCORE_LOCATION}/include ...) target_link_libraries(main android playcore ...)
डेटा का संग्रह
Play Core Native SDK, वर्शन से जुड़ा डेटा इकट्ठा कर सकता है. इससे Google को प्रॉडक्ट को बेहतर बनाने में मदद मिलती है. इसमें यह डेटा शामिल है:
- ऐप्लिकेशन के पैकेज का नाम
- ऐप्लिकेशन के पैकेज का वर्शन
- Play Core Native SDK टूल का वर्शन
यह डेटा तब इकट्ठा किया जाएगा, जब Play Console में अपना ऐप्लिकेशन पैकेज अपलोड किया जाएगा. डेटा इकट्ठा करने की इस प्रोसेस से ऑप्ट-आउट करने के लिए, build.gradle फ़ाइल से $playcoreDir/playcore-native-metadata.jar
इंपोर्ट हटाएं.
ध्यान दें कि Play Core Native SDK के आपके इस्तेमाल से जुड़ा यह डेटा कलेक्शन और Google के इस्तेमाल से इकट्ठा किया गया डेटा, Google के उस डेटा कलेक्शन से अलग और स्वतंत्र है जो Gradle में लाइब्रेरी डिपेंडेंसी के तौर पर बताया जाता है. यह डेटा तब इकट्ठा किया जाता है, जब Play Console पर अपना ऐप्लिकेशन पैकेज अपलोड किया जाता है.
Play Core Native SDK को अपने प्रोजेक्ट में इंटिग्रेट करने के बाद, एपीआई कॉल करने वाली फ़ाइलों में यह लाइन शामिल करें:
review.h को शामिल करें
अपने प्रोजेक्ट में Play Core Native SDK को इंटिग्रेट करने के बाद, एपीआई कॉल वाली फ़ाइलों में यह लाइन शामिल करें:
#include "play/review.h"
Review API को शुरू करना
जब भी आपको एपीआई का इस्तेमाल करना हो, तो आपको सबसे पहले इसे शुरू करना होगा. इसके लिए, ReviewManager_init
फ़ंक्शन को कॉल करें. यहां दिए गए उदाहरण में, android_native_app_glue.h
का इस्तेमाल करके इसे बनाया गया है:
void android_main(android_app* app) {
app->onInputEvent = HandleInputEvent;
ReviewErrorCode error_code = ReviewManager_init(app->activity->vm, app->activity->clazz);
if (error_code == REVIEW_NO_ERROR) {
// You can use the API.
}
}
ऐप्लिकेशन में समीक्षा करने की सुविधा के लिए अनुरोध करना
ऐप्लिकेशन में समीक्षा का अनुरोध कब करना चाहिए, इस बारे में दिए गए दिशा-निर्देशों का पालन करें. इससे आपको अपने ऐप्लिकेशन के उपयोगकर्ता फ़्लो में ऐसे अच्छे पॉइंट तय करने में मदद मिलेगी जहां उपयोगकर्ता से समीक्षा करने के लिए कहा जा सकता है. उदाहरण के लिए, किसी गेम में लेवल पूरा होने के बाद, जब उपयोगकर्ता खास जानकारी वाली स्क्रीन को खारिज कर देता है. जब आपका ऐप्लिकेशन इनमें से किसी एक पॉइंट के करीब पहुंच जाए, तो ReviewManager_requestReviewFlow
को कॉल करें. इससे, आपके ऐप्लिकेशन को इन-ऐप्लिकेशन समीक्षा फ़्लो लॉन्च करने के लिए ज़रूरी जानकारी एसिंक्रोनस तरीके से मिल जाएगी. ReviewManager_requestReviewFlow
ऑपरेशन की प्रोग्रेस को मॉनिटर करें. इसके लिए, ReviewManager_getReviewStatus
को कॉल करें. उदाहरण के लिए, हर फ़्रेम में एक बार. इसमें कुछ सेकंड लग सकते हैं. इसलिए, आपको यह प्रोसेस तब शुरू करनी चाहिए, जब आपका ऐप्लिकेशन उस पॉइंट पर पहुंच जाए जहां आपको ऐप्लिकेशन की समीक्षा करने का फ़्लो दिखाना है.
ReviewErrorCode error_code = ReviewManager_requestReviewFlow();
if (error_code == REVIEW_NO_ERROR) {
// The request has successfully started, check the status using
// ReviewManager_getReviewStatus.
} else {
// Error such as REVIEW_PLAY_STORE_NOT_FOUND indicating that the in-app
// review isn't currently possible.
}
स्टेटस मैनेज करना और ऐप्लिकेशन में समीक्षा करने की सुविधा लॉन्च करना
जब भी कोई अनुरोध शुरू हो जाता है या ऐप्लिकेशन में समीक्षा करने की प्रोसेस शुरू हो जाती है, तब ReviewManager_getReviewStatus
का इस्तेमाल करके स्थिति देखी जा सकती है. इससे, एपीआई की स्थिति के आधार पर लॉजिक तय किया जा सकता है. इसके लिए, स्टेटस को ��्लोबल वैरिएबल के तौर पर सेट किया जा सकता है. साथ ही, यह देखा जा सकता है कि जब उपयोगकर्ता कोई कार्रवाई करता है, तब स्टेटस REVIEW_REQUEST_FLOW_COMPLETED
है या नहीं. उदाहरण के लिए, जब उपयोगकर्ता किसी गेम में "अगला लेवल" बटन पर टैप करता है, तब स्टेटस REVIEW_REQUEST_FLOW_COMPLETED
है या नहीं. इसे यहां दिए गए उदाहरण में दिखाया गया है:
ReviewStatus status;
ReviewErrorCode error_code = ReviewManager_getReviewStatus(&status);
if (error_code != REVIEW_NO_ERROR) {
// There was an error with the most recent operation.
return;
}
switch (status) {
case REVIEW_REQUEST_FLOW_PENDING:
// Request is ongoing. The flow can't be launched yet.
break;
case REVIEW_REQUEST_FLOW_COMPLETED:
// Request completed. The flow can be launched now.
break;
case REVIEW_LAUNCH_FLOW_PENDING:
// The review flow is ongoing, meaning the dialog might be displayed.
break;
case REVIEW_LAUNCH_FLOW_COMPLETED:
// The review flow has finished. Continue with your app flow (for
// example, move to the next screen).
break;
default:
// Unknown status.
break;
}
जब स्टेटस REVIEW_REQUEST_FLOW_COMPLETED
हो और आपका ऐप्लिकेशन तैयार हो जाए, तब ऐप्लिकेशन में समीक्षा करने की सुविधा लॉन्च करें:
// This call uses android_native_app_glue.h. ReviewErrorCode error_code = ReviewManager_launchReviewFlow(app->activity->clazz); if (error_code != REVIEW_NO_ERROR) { // There was an error while launching the flow. return; }
ऐप्लिकेशन में समीक्षा करने की सुविधा लॉन्च करने के बाद, इसकी स्थिति देखते रहें. साथ ही, ऐप्लिकेशन का इस्तेमाल जारी रखें. इस समस्या को हल करने का एक सामान्य तरीका यह है कि गेम लूप पैटर्न का इस्तेमाल किया जाए.
मुफ़्त संसाधन
जब आपका ऐप्लिकेशन एपीआई का इस्तेमाल करना बंद कर दे, तब ReviewManager_destroy
फ़ंक्शन को कॉल करके संसाधनों को खाली करना न भूलें. उदाहरण के लिए, ऐप्लिकेशन में समीक्षा का फ़्लो पूरा होने के बाद.
void ReviewManager_destroy();
अगले चरण
अपने ऐप्लिकेशन में, ऐप्लिकेशन की समीक्षा करने की सुविधा के फ़्लो की जांच करें. इससे यह पुष्टि की जा सकेगी कि आपका इंट��ग्रेशन सही तरीके से काम कर रहा है.