本页内容

应用内购买演示 - iOS 类

以下类属于应用内购买演示的一部分:

类

IosInAppPurchaseProduct在商店中注册的产品。
IosInAppPurchaseTransaction包含有关外部应用商店中某笔交易的信息。
IosInAppPurchaseBackend与外部应用商店进行通信。

请查看应用内购买演示——基础类包括 InAppProduct、InAppStore、InAppTransaction 和 InAppPurchaseBackend

IosInAppPurchaseProduct

IosInAppPurchaseProduct 添加了 purchase() 方法,用于初始化购买流程。

IosInAppPurchaseTransaction

IosInAppPurchaseTransaction 添加了新的参数和返回类型。交易错误处理在 IosInAppPurchaseTransaction 的构造函数中实现。该类拥有 finalize() 函数,用于终止交易。

IosInAppPurchaseBackend

IosInAppPurchaseBackend 使用Objective-C语言与 App Store 进行通信。

初始化产品

该类用于在商店页面上显示产品的信息。

  1. IosInAppPurchaseBackend 由 InAppStore::setupBackend() 调用。
  2. 在初始化时,IosInAppPurchaseBackend 使用 Objective-C 创建 InAppPurchaseManager。
  3. 调用 InAppStore::registerProduct(productType, &identifier) 函数,并在后端执行 queryProduct()。
  4. 调用 Objective-C 函数 requestProductData:(),并生成SKProductRequest。
  5. SKProductRequest 完成后,并在 Objective-C 的 productsRequest:( ) 中创建了产品对象,产品将由 IosInAppPurchaseBackend::registerProduct() 函数进行注册。
  6. 将发出 productQueryDone() 信号,该项目的信息将在应用程序的商店页面上显示。

购买流程

  1. 用户点击应用程序商店页面上的某件商品。
  2. IosInAppPurchaseProduct::purchase() 调用该函数,并在 IosInAppPurchaseBackend 的 Objective-C 函数 paymentQueue:( ) 中将付款添加到支付队列(SKPaymentQueue )中。
  3. 系统将为用户弹出购买确认窗口。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.