The paywallViewDidFinishPurchase
handler in AdaptyUIObserver
is correctly triggered at the end of the purchase on Android, but on iOs it's never triggered.
All the test that I did were in sandbox environment.
My flutter doctor output is the following:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.7, on macOS 13.6 22G120 darwin-arm64, locale it-IT)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
[✓] Android Studio (version 2022.3)
[✓] IntelliJ IDEA Community Edition (version 2022.2.3)
[✓] VS Code (version 1.83.0)
[✓] Connected device (2 available)
[✓] Network resources
• No issues found!
The pubspec.yaml contains the following dependencies version:
adapty_flutter: ^2.7.0
adapty_ui_flutter: ^2.0.1
Here you can find a sample app to reproduce the bug.
import 'package:adapty_flutter/adapty_flutter.dart';
import 'package:adapty_ui_flutter/adapty_ui_flutter.dart';
import 'package:flutter/material.dart';
class CustomAdaptyUIObserver extends AdaptyUIObserver {
@override
void paywallViewDidPerformAction(AdaptyUIView view, AdaptyUIAction action) {
switch (action.type) {
case AdaptyUIActionType.close:
case AdaptyUIActionType.androidSystemBack:
view.dismiss();
break;
case AdaptyUIActionType.openUrl:
default:
break;
}
}
@override
void paywallViewDidSelectProduct(
AdaptyUIView view, AdaptyPaywallProduct product) {
debugPrint("paywallViewDidSelectProduct");
}
@override
void paywallViewDidStartPurchase(
AdaptyUIView view, AdaptyPaywallProduct product) {
debugPrint("paywallViewDidStartPurchase");
}
@override
void paywallViewDidCancelPurchase(
AdaptyUIView view, AdaptyPaywallProduct product) {
debugPrint("paywallViewDidCancelPurchase");
}
@override
void paywallViewDidFinishPurchase(
AdaptyUIView view, AdaptyPaywallProduct product, AdaptyProfile profile) {
// this is never printed
debugPrint("paywallViewDidFinishPurchase");
view.dismiss();
}
@override
void paywallViewDidFailPurchase(
AdaptyUIView view, AdaptyPaywallProduct product, AdaptyError error) {
debugPrint("paywallViewDidFailPurchase");
}
@override
void paywallViewDidFinishRestore(AdaptyUIView view, AdaptyProfile profile) {
debugPrint("paywallViewDidFinishRestore");
}
@override
void paywallViewDidFailRestore(AdaptyUIView view, AdaptyError error) {
debugPrint("paywallViewDidFailRestore");
}
@override
void paywallViewDidFailRendering(AdaptyUIView view, AdaptyError error) {
debugPrint("paywallViewDidFailRendering");
}
@override
void paywallViewDidFailLoadingProducts(AdaptyUIView view, AdaptyError error) {
debugPrint("paywallViewDidFailLoadingProducts");
}
}
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
late Adapty adapty;
late AdaptyUI adaptyUI;
@override
void initState() {
super.initState();
adapty = Adapty();
adapty.activate();
adaptyUI = AdaptyUI();
adaptyUI.addObserver(CustomAdaptyUIObserver());
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: SafeArea(
child: Center(
child: ElevatedButton(
child: const Text("Paywall"),
onPressed: () async {
final paywall = await adapty.getPaywall(
id: "PLACEMENT_ID",
);
final AdaptyUIView view = await adaptyUI.createPaywallView(
paywall: paywall,
locale: 'en',
);
await view.present();
},
),
),
),
);
}
}