Android - 使用备用付费墙

Warning

备用付费墙需要 Android SDK v2.11 及更高版本支持。

为了保持流畅的用户体验,请务必为你的流程、付费墙和用户引导设置备用方案。这一预防措施可以在网络连接部分或完全中断时,保障应用的正常使用。

  • 如果应用无法访问 Adapty 服务器:

    应用仍可显示备用流程或付费墙,并访问本地用户引导配置。

  • 如果应用无法访问网络:

    应用仍可显示备用流程或付费墙。用户引导包含远程内容,需要网络连接才能正常运行。

Important

在执行本指南中的步骤之前,请先从 Adapty 看板或通过终端命令 adapty fallbacks get 下载备用配置文件。

配置

  1. 将备用配置文件移动到 Android 项目的 assets 或 res/raw 目录中。
  2. 在获取目标流程、付费墙或用户引导之前,调用 .setFallback 方法。
//if you put the 'android_fallback.json' file to the 'assets' directory
val location = FileLocation.fromAsset("android_fallback.json")
//or `FileLocation.fromAsset("<additional_folder>/android_fallback.json")` if you placed it in a child folder of 'assets')

//if you put the 'android_fallback.json' file to the 'res/raw' directory
val location = FileLocation.fromResId(context, R.raw.android_fallback)

//you can also pass a file URI
val fileUri: Uri = //get Uri for the file with fallback paywalls
val location = FileLocation.fromFileUri(fileUri)

//pass the file location
Adapty.setFallback(location, callback)

参数:

参数描述
location备用配置文件的 FileLocation 对象