การติดตั้งในบรรทัดของ Google Play (App Store ของบุคคลที่สาม)

หน้านี้อธิบายวิธีที่ App Store ของบุคคลที่สามที่ลงทะเบียนเข้าร่วมโปรแกรมการเข้าถึงแคตตาล็อก สามารถผสานรวม การติดตั้งในบรรทัด ของ Google Play ซึ่งเป็นฟีเจอร์ที่ช่วยให้ Android App Store ของบุคคลที่สามในสหรัฐอเมริกาสามารถนำผู้ใช้ไปดาวน์โหลดแอป Android ของ Google Play ผ่าน Google Play โดยมีข้อกำหนดเดียวกันกับการดาวน์โหลดอื่นๆ ที่ดำเนินการผ่าน Google Play Store โดยตรง

สิ่งที่ต้องมีก่อน

ก่อนที่จะผสานรวม API การติดตั้งในบรรทัดใน App Store ของบุคคลที่สาม คุณต้องตั้งค่าต่อไปนี้ใน Google Play Console ให้เสร็จสมบูรณ์

  1. ลงทะเบียนเข้าร่วมโปรแกรมการเข้าถึงแคตตาล็อกของ Google Play: ทำตาม วิธีการลงทะเบียน
  2. เลือกใช้การเข้าถึงแคตตาล็อก: ลงทะเบียนเข้าร่วมโปรแกรมการเข้าถึงแคตตาล็อกผ่านการตั้งค่า Play Console
  3. ดึงข้อมูลโทเค็นการส่ง: ประมวลผลการส่งออกแคตตาล็อกแอป Google Play ที่เรามอบให้ การส่งออกนี้มี catalog_token (โทเค็นการส่ง) ที่จำเป็นสำหรับแต่ละแอปที่คุณมีสิทธิ์เผยแพร่

ข้อกำหนด

อินเทอร์เฟซแบบครึ่งหน้าจะปรากฏแก่ผู้ใช้ได้สำเร็จเมื่อเป็นไปตามข้อกำหนดต่อไปนี้

  • ผู้ใช้ต้องอยู่ในสหรัฐอเมริกา
  • Google Play เวอร์ชันต่ำสุดในอุปกรณ์ต้องเป็นเวอร์ชัน 52.3
  • ระดับ API ของ Android ต้องเป็น 24 ขึ้นไป
  • คุณต้องระบุ catalog_token ที่ถูกต้องและไม่หมดอายุเพื่อเข้าถึง Play Store

เรียกใช้การติดตั้งในบรรทัดจาก App Store

หากต้องการเรียกใช้อินเทอร์เฟซแบบครึ่งหน้าสำหรับการติดตั้งในบรรทัด ให้สร้างอินสแตนซ์ของคลาส Intent ที่กำหนดเป้าหมายเป็น URL Deep Link ของ Google Play และมี catalog_token ที่ไม่ซ้ำกัน

ใช้โค้ดตัวอย่างต่อไปนี้ (Kotlin หรือ Java) เป็นแนวทาง

Kotlin

val intent = Intent(Intent.ACTION_VIEW)
val referrer = "<Your referrer string>"
val id = "<Package name of the app to be installed>"
val callerId = "<Package name of your third-party app store>"

// Retrieve the app-specific token from your processed catalog export
val catalogToken = getVerificationTokenByDocId(id)

intent.setPackage("com.android.vending")
val deepLinkUrl = "https://play.google.com/d?id=$id&referrer=$referrer"
intent.data = Uri.parse(deepLinkUrl)

// Set the required intent extras
intent.putExtra("overlay", true)
intent.putExtra("callerId", callerId)
intent.putExtra("catalog_token", catalogToken)

val packageManager = context.getPackageManager()
if (intent.resolveActivity(packageManager) != null) {
  startActivityForResult(intent, 0) // Call with a request code to receive ActivityResults
}

Java

Intent intent = new Intent(Intent.ACTION_VIEW);
String referrer = "<Your referrer string>";
String id = "<Package name of the app to be installed>";
String callerId = "<Package name of your third-party app store>";

// Retrieve the app-specific token from your processed catalog export
String catalogToken = getVerificationTokenByDocId(id);

intent.setPackage("com.android.vending");
String deepLinkUrl = "https://play.google.com/d?id=" + id + "&referrer=" + referrer;
intent.setData(Uri.parse(deepLinkUrl));

// Set the required intent extras
intent.putExtra("overlay", true);
intent.putExtra("callerId", callerId);
intent.putExtra("catalog_token", catalogToken);

PackageManager packageManager = context.getPackageManager();
if (intent.resolveActivity(packageManager) != null) {
  startActivityForResult(intent, 0); // Call with a request code to receive ActivityResults
}

พารามิเตอร์ API การติดตั้งในบรรทัด

คุณต้องส่งพารามิเตอร์ต่อไปนี้ใน URL ของ Intent หรือเป็น Intent Extra เพื่อให้สิทธิ์การติดตั้งในบรรทัด

ช่อง ประเภท ตำแหน่ง คำอธิบาย ต้องระบุ
id String การค้นหา URL ชื่อแพ็กเกจของแอปเป้าหมายที่จะติดตั้ง ใช่
referrer String การค้นหา URL สตริงการติดตามผู้แนะนำแบบไม่บังคับ ไม่
overlay boolean Intent Extra ตั้งค่าเป็น true เพื่อขออินเทอร์เฟซแบบครึ่งหน้าสำหรับการติดตั้งในบรรทัด ใช่
callerId String Intent Extra ชื่อแพ็กเกจของ App Store ของบุคคลที่สามที่ได้รับอนุมัติ ใช่
catalog_token String Intent Extra โทเค็นการส่งที่ไม่ซ้ำกันซึ่งระบุไว้ในการส่งออกการเข้าถึงแคตตาล็อก หมายเหตุ: ระบบจะตรวจสอบโทเค็นว่าใหม่หรือไม่ แอปเป้าหมายตรงกันหรือไม่ และแพ็กเกจของผู้เรียกตรงกันหรือไม่ ใช่

(ไม่บังคับ) การติดตั้งในบรรทัดของ Google Play พร้อมการวางซ้อนสถานะการติดตั้ง

หากต้องการแสดงการวางซ้อนสถานะการติดตั้งพร้อมโฟลว์การติดตั้งในบรรทัด คุณจะต้องผสานรวมการติดตั้งในบรรทัดของ Google Play กับฟีเจอร์ Persistent Affordance โดยใช้ Google Play HSDP SDK

โฟลว์การติดตั้งในบรรทัดพร้อม Persistent Affordance จะปรากฏขึ้นเมื่อเป็นไปตามเงื่อนไขต่อไปนี้

  • Google Play Store เวอร์ชันต่ำสุดของอุปกรณ์เป้าหมายต้องเป็นเวอร์ชัน 52.6 ขึ้นไป
  • ระดับ API ของ Android ต้องเป็น 24 (Android M) ขึ้นไป
  • ผสานรวมกับ HSDP SDK เวอร์ชัน 2.1.0 ขึ้นไป

ตัวอย่างการผสานรวม

Kotlin

// Step 1: Initialize HSDP Service
// Note: Calling create(activity) automatically configures useServiceBasedHsdp = false
// (Activity Path) under the hood without requiring manual boolean flags.
val hsdpService = HsdpDeepLinkServiceFactory.create(activity)

// Step 2: Construct Extra Query Parameters with Catalog Token
val extraQueryParams = mapOf("catalog_token" to "YOUR_SECURE_CATALOG_TOKEN_VALUE")

// Step 3: Trigger Inline Install Flow
hsdpService.open(
    targetAppPackageName = "com.example.targetapp",
    referrer = "3pas_ad_campaign_123",
    listener = object : HsdpDeepLinkServiceListener {
        override fun onDeepLinkStarted() {
            // Inline details dialog started successfully
        }
        override fun onAffordanceStarted() {
            // HPOA persistent affordance UI attached
        }
        override fun onAffordanceEnded() {
            // Affordance UI detached
        }
        override fun onError(errorMessage: String) {
            // Handle error or fallback
        }
    },
    extraQueryParams = extraQueryParams
)

Java

// Step 1: Initialize HSDP Service
// Note: Calling create(activity) automatically configures useServiceBasedHsdp = false
// (Activity Path) under the hood without requiring manual boolean flags.
HsdpDeepLinkService hsdpService = HsdpDeepLinkServiceFactory.create(activity);

// Step 2: Construct Extra Query Parameters with Catalog Token
Map<String, String> extraQueryParams = new HashMap<>();
extraQueryParams.put("catalog_token", "YOUR_SECURE_CATALOG_TOKEN_VALUE");

// Step 3: Trigger Inline Install Flow
hsdpService.open(
    "com.example.targetapp",
    "3pas_ad_campaign_123",
    new HsdpDeepLinkServiceListener() {
      @Override
      public void onDeepLinkStarted() {
        // Inline details dialog started successfully
      }

      @Override
      public void onAffordanceStarted() {
        // HPOA persistent affordance UI attached
      }

      @Override
      public void onAffordanceEnded() {
        // Affordance UI detached
      }

      @Override
      public void onError(String errorMessage) {
        // Handle error or fallback
      }
    },
    extraQueryParams);

ตัวอย่างการหยุดติดตาม Affordance

อนุญาตให้แอปของผู้เรียกหยุดติดตามสถานะการติดตั้งและปิดการวางซ้อน HPOA ด้วยตนเอง หมายเหตุ: การดำเนินการนี้จะไม่ปิดชีตการติดตั้ง HSDP เอง แต่จะปิดเฉพาะ Affordance

Kotlin

// Stop tracking the installation state and dismiss the affordance overlay
hsdpService.stopAffordance(
    targetAppPackageName = "com.example.targetapp",
    listener = object : HsdpDeepLinkService.AffordanceListener {
        override fun onAffordanceStopped() {
            // Affordance overlay stopped successfully
        }
    }
)

Java

// Stop tracking the installation state and dismiss the affordance overlay
hsdpService.stopAffordance(
    "com.example.targetapp",
    new HsdpDeepLinkService.AffordanceListener() {
      @Override
      public void onAffordanceStopped() {
        // Affordance overlay stopped successfully
      }
    });

สถานะและ UX ของ Affordance

ฟีเจอร์การติดตั้งในบรรทัดของ Google Play พร้อม Persistent Affordance มี 2 สถานะภาพดังนี้

  1. สถานะการติดตั้ง: แสดงภาพขนาดย่อของแอปเป้าหมายและวงกลมแสดงความคืบหน้าการติดตั้ง การคลิกภาพขนาดย่อจะเปิดชีตการติดตั้ง HSDP อีกครั้ง
  2. สถานะหลังการติดตั้ง: แสดงไอคอนแอปเป้าหมายพร้อมการดำเนินการ "เปิด" การคลิกภาพขนาดย่อจะเปิดแอปที่ติดตั้งใหม่
กำลังติดตั้ง หลังการติดตั้ง
สถานะการติดตั้ง (ขยาย)

สถานะการติดตั้ง (ยุบ)
สถานะหลังการติดตั้ง