Paywall dự phòng được hỗ trợ bởi Android SDK v2.11 trở lên.
Để duy trì trải nghiệm người dùng mượt mà, điều quan trọng là phải thiết lập paywall dự phòng cho các flow, paywall và onboarding của bạn. Biện pháp phòng ngừa này giúp mở rộng khả năng của ứng dụng trong trường hợp mất kết nối internet một phần hoặc hoàn toàn.
Nếu ứng dụng không thể kết nối đến máy chủ Adapty:
Ứng dụng vẫn có thể hiển thị flow hoặc paywall dự phòng, và truy cập cấu hình onboarding đã lưu cục bộ.
Nếu ứng dụng không thể kết nối internet:
Ứng dụng vẫn có thể hiển thị flow hoặc paywall dự phòng. Onboarding chứa nội dung từ xa và cần có kết nối internet để hoạt động.
Trước khi thực hiện các bước trong hướng dẫn này, hãy tải xuống các file cấu hình dự phòng từ Adapty.
Cấu hình
Di chuyển file cấu hình dự phòng vào thư mục assets hoặc res/raw trong dự án Android của bạn.
Gọi phương thức .setFallbacktrước khi bạn lấy paywall hoặc onboarding mục tiêu.
//if you put the 'android_fallback.json' file to the 'assets' directoryval 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' directoryval location = FileLocation.fromResId(context, R.raw.android_fallback)//you can also pass a file URIval fileUri: Uri = //get Uri for the file with fallback paywallsval location = FileLocation.fromFileUri(fileUri)//pass the file locationAdapty.setFallback(location, callback)
//if you put the 'android_fallback.json' file to the 'assets' directoryFileLocation 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' directoryFileLocation location = FileLocation.fromResId(context, R.raw.android_fallback);//you can also pass a file URIUri fileUri = //get Uri for the file with fallback paywallsFileLocation location = FileLocation.fromFileUri(fileUri);//pass the file locationAdapty.setFallback(location, callback);