इन-ऐप्लिकेशन समीक्षाएं इंटिग्रेट करें (नेटिव)

इस गाइड में नेटिव विज्ञापनों का इस्तेमाल करके, अपने ऐप्लिकेशन में इन-ऐप्लिकेशन समीक्षाओं को इंटिग्रेट करने का तरीका बताया गया है (C या C++) कोड इस्तेमाल करें. अगर Kotlin की मदद ली जा रही है, तो इंटिग्रेशन गाइड अलग-अलग हैं या Java या Unity.

नेटिव SDK टूल की खास जानकारी

Play Core नेटिव SDK टूल, Google Play Core लाइब्रेरी का हिस्सा है परिवार. Play Core नेटिव SDK टूल में एक C हेडर फ़ाइल, review.h शामिल होती है. रैप ReviewManager को आसानी से ट्रैक किया जा सकता है. इस हेडर फ़ाइल की मदद से आपका ऐप्लिकेशन ये काम कर सकता है एपीआई को सीधे अपने नेटिव कोड से कॉल करें. लोगों की खास जानकारी के लिए उपलब्ध फ़ंक्शन के लिए, Play Review नेटिव मॉड्यूल देखें दस्तावेज़ में दिया गया है.

ReviewManager_requestReviewFlow एक अनुरोध शुरू करता है, जो इन-ऐप्लिकेशन समीक्षा की प्रोसेस को बाद में पूरा करें. अनुरोध के नतीजे को ट्रैक करने के लिए, इनका इस्तेमाल करें: ReviewManager_getReviewStatus. उन सभी स्थितियों के बारे में ज़्यादा जानकारी पाने के लिए जो ReviewManager_getReviewStatus वापस आ सकते हैं, ReviewErrorCode देखें.

अनुरोध और लॉन्च करने वाले फ़ंक्शन, REVIEW_NO_ERROR नतीजे दिखाते हैं, अगर: फ़ंक्शन सफल होता है.

अपना डेवलपमेंट एनवायरमेंट सेट अप करें

Download Play Core Native SDK

Before downloading, you must agree to the following terms and conditions.

Terms and Conditions

Last modified: September 24, 2020
  1. 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.
  2. For purposes of these terms, "APIs" means Google's APIs, other developer services, and associated software, including any Redistributable Code.
  3. “Redistributable Code” means Google-provided object code or header files that call the APIs.
  4. 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.
  5. 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.
Download Play Core Native SDK

play-core-native-sdk-1.14.0.zip

  1. इनमें से कोई एक काम करें:

    • Android Studio का 4.0 या इसके बाद वाला वर्शन इंस्टॉल करें. SDK टूल का इस्तेमाल करना Android SDK प्लैटफ़ॉर्म के वर्शन 10.0 (एपीआई लेवल 29) को इंस्टॉल करने के लिए, मैनेजर के यूज़र इंटरफ़ेस (यूआई) की इमेज.
    • Android SDK टूल के कमांड-लाइन टूल इंस्टॉल करें और इसे इंस्टॉल करने के लिए sdkmanager का इस्तेमाल करें Android SDK प्लैटफ़ॉर्म का वर्शन 10.0 (एपीआई लेवल 29).
  2. इनका इस्तेमाल करके, अपने ऐप्लिकेशन को बेहतर बनाने के लिए Android Studio को तैयार करें नया वर्शन इंस्टॉल करने के लिए, SDK Manager CMake और Android नेटिव डेवलपमेंट किट (NDK). अगर आपको ज़्यादा जानकारी चाहिए, तो नेटिव प्रोजेक्ट बनाना या इंपोर्ट करना, तो एनडीके (NDK) के साथ शुरुआत करना.

  3. ZIP फ़ाइल डाउनलोड करें और उसे अपने प्रोजेक्ट के साथ एक्सट्रैक्ट करें.

    लिंक डाउनलोड करें साइज़ SHA-256 चेकसम
    36 एमआईबी 782a8522d937848c83a715c9a258b95a3ff2879a7cd71855d137b41c00786a5e
  4. नीचे बताए गए तरीके से अपने ऐप्लिकेशन की 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.2.2'
            implementation 'com.google.android.play:integrity:1.4.0'
            implementation 'com.google.android.play:review:2.0.1'
    
            // 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.2.2")
        implementation("com.google.android.play:integrity:1.4.0")
        implementation("com.google.android.play:review:2.0.1")
    
        // Import these common dependencies.
        implementation("com.google.android.gms:play-services-tasks:18.0.2")
        implementation(files("$playcoreDir/playcore-native-metadata.jar"))
        ...
    }
    
  5. अपने ऐप्लिकेशन की 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 नेटिव SDK टूल, वर्शन से जुड़ा डेटा इकट्ठा कर सकता है, ताकि Google इन कामों को कर सके बेहतर बनाने के लिए, इनमें शामिल हैं:

  • ऐप्लिकेशन के पैकेज का नाम
  • ऐप्लिकेशन का पैकेज वर्शन
  • मुख्य नेटिव SDK टूल का वर्शन चलाएं

यह डेटा, अपना ऐप्लिकेशन पैकेज अपलोड करने पर इकट्ठा किया जाएगा Play Console में जाएं. इस डेटा कलेक्शन प्रोसेस से ऑप्ट-आउट करने के लिए, बिल्ड.gradle फ़ाइल में $playcoreDir/playcore-native-metadata.jar इंपोर्ट करते हैं.

ध्यान दें, यह डेटा कलेक्शन, Play Core नेटिव SDK टूल और Google, इकट्ठा किए गए डेटा का अलग-अलग तरीके से इस्तेमाल करता है. यह Google के डेटा से अलग होता है ऐप्लिकेशन अपलोड करते समय, Gradle में बताई गई लाइब्रेरी डिपेंडेंसी का कलेक्शन पैकेज को Play Console से जोड़ना होगा.

Play Core नेटिव SDK टूल को अपने प्रोजेक्ट में इंटिग्रेट करने के बाद, एपीआई कॉल वाली फ़ाइलों की नीचे दी गई लाइन में:

समीक्षा.h शामिल करें

अपने प्रोजेक्ट में Play Core नेटिव SDK टूल को इंटिग्रेट करने के बाद, नीचे दी गई फ़ाइल में एपीआई कॉल शामिल होंगे:

#include "play/review.h"

समीक्षा एपीआई को शुरू करें

जब भी आप 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 होता है कार्रवाई (उदाहरण के लिए, किसी गेम में “अगला लेवल” बटन पर टैप करना), जैसा कि नीचे दिया गया उदाहरण:

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();

अगले चरण

अपने ऐप्लिकेशन की इन-ऐप्लिकेशन समीक्षा की प्रोसेस की जांच करना पुष्टि करें कि आपका इंटिग्रेशन सही तरीके से काम कर रहा है.