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

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

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

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

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

ข้อกำหนด

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

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

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

หากต้องการเรียกใช้แบบครึ่งหน้าจอสำหรับการติดตั้งจากในหน้าเว็บ ให้สร้างอินสแตนซ์ของ Intent คลาสที่กำหนดเป้าหมายเป็น Google Play URL Deep Link และมี 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
byte[] 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 การค้นหา URL ชื่อแพ็กเกจของแอปเป้าหมายที่จะติดตั้ง ใช่
referrer การค้นหา URL สตริงการติดตามผู้แนะนำแบบไม่บังคับ ไม่
overlay Intent Extra ตั้งค่าเป็น true เพื่อขออินเทอร์เฟซแบบครึ่งหน้าจอสำหรับการติดตั้งจากในหน้าเว็บ ใช่
callerId Intent Extra ชื่อแพ็กเกจของ App Store ของบุคคลที่สามที่ได้รับอนุมัติ ใช่
catalog_token Intent Extra โทเค็นการส่งที่ไม่ซ้ำกันซึ่งระบุไว้ในการส่งออกการเข้าถึงแคตตาล็อก หมายเหตุ: ระบบจะตรวจสอบโทเค็นว่าใหม่หรือไม่ แอปเป้าหมายตรงกันหรือไม่ และแอปที่เรียกใช้ตรงกันหรือไม่ ใช่

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

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

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

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

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

// 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
)

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

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

// 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
        }
    }
)

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

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

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

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