SuperAPI AI 工具集

configuring-the-sdk

通用与其它

查看项目

更新于 10-16 07:58

技能介绍

用途:在 Android 应用中接入并配置 RevenueCat Android SDK(purchases-kt/purchases)。一次 Purchases.configure 调用即可替代 BillingClient 初始化、连接生命周期管理、重连处理与启动时购买查询。

主要能力:覆盖发现、规划与执行三个阶段。发现阶段用 rg 搜索现有配置与账单代码,例如:rg -n "Purchases.configure|PurchasesConfiguration" --type kotlin --type java;rg -n "com.revenuecat.purchases" -g '.gradle' -g '*.toml';rg -n "BillingClient|PurchasesUpdatedListener|startConnection" --type kotlin --type java。规划阶段确定 configure 调用位置、App User ID 策略与日志级别。执行阶段添加依赖并在启动时调用 configure。

必要用法:在 app 模块 build.gradle.kts 添加 implementation("com.revenuecat.purchases:purchases:<latest>"),Groovy 用 implementation 'com.revenuecat.purchases:purchases:<latest>'。在 Application.onCreate 中设置日志级别并调用 Purchases.configure,通过 PurchasesConfiguration.Builder(this, BuildConfig.RC_API_KEY).appUserID(null)(或稳定用户 ID)构建,并在 AndroidManifest.xml 的 <application> 上注册 android:name=".App"。可用 awaitOfferings() 验证接线,offerings.current 非空表示可用。

限制与注意:configure 每进程只调用一次;若已存在需先与用户确认。不要传设备 ID、邮箱或可变值。API 密钥勿写入源码,应通过 BuildConfig 或密钥管理注入。常见问题包括 configure 前访问单例、包名不匹配导致 offerings 为 null、重复匿名用户、生产环境日志过多。资料未提供具体最新版本号与完整官方章节内容。