Приложение iOS завершается при использовании in_app_purchase в 18.3.1 в FlutterIOS

Программируем под IOS
Ответить
Anonymous
 Приложение iOS завершается при использовании in_app_purchase в 18.3.1 в Flutter

Сообщение Anonymous »

Я изучаю трепетание и реализовал in_app_purchase для Android и iOS, однако он отлично работает в обеих платформах, но имея приведенный ниже выпуск в iOS 18.3.1. Версия, которую я имею < /p>
in_app_purchase: ^3.1.13
< /code>
Я сталкиваюсь с этой проблемой < /p>
flutter: Purchase successful!
flutter: Purchase finally :
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance 0x20c8db910'
*** First throw call stack:
(0x1a266a5fc 0x19fbe5244 0x1a27c3174 0x1a266d5c8 0x1a266cef0 0x1a125bbf0 0x1cfc08f64 0x1cfc066a8 0x1cfc05d18 0x1cfc052f4 0x1cfc07811 0x1cfc09a29 0x1cfbe2ddd 0x1cfbe2ddd 0x1cfbe2ddd 0x1cfbde2c5 0x1cfbde419 0x1cfbde2c5 0x1adf8fe39)
libc++abi: terminating due to uncaught exception of type NSException
< /code>
Мой исходный код < /p>
Future purchasePlan(BasePlans basePlan, BuildContext context) async {
try {
isLoading.value = true;
print("purchasePlan called : " + basePlan.id.toString());
print("purchasePlan called : " + basePlan.productDetails!.title);

if (basePlan.productDetails == null) {
error.value = "Product not available for purchase.";
print("Product not available for purchase");
isLoading.value = false;
return;
}
purchasePending.value = true;
late PurchaseParam purchaseParam;

if (Platform.isAndroid) {
// Check for existing subscriptions
final GooglePlayPurchaseDetails? oldSubscription =
_getOldSubscription(basePlan.productDetails!, purchases);
purchaseParam = GooglePlayPurchaseParam(
productDetails: basePlan.productDetails!,
changeSubscriptionParam: (oldSubscription != null)
? ChangeSubscriptionParam(
oldPurchaseDetails: oldSubscription,
replacementMode: ReplacementMode.withoutProration)
: null,
);
} else {

print("basePlan.productDetails id: " + basePlan.productDetails!.id);
print("basePlan.productDetails title : " +
basePlan.productDetails!.title);
print("basePlan.productDetails description : " +
basePlan.productDetails!.description);
print("basePlan.productDetails price : " +
basePlan.productDetails!.price);
print("basePlan.productDetails rawPrice: " +
basePlan.productDetails!.rawPrice.toString());
print("basePlan.productDetails currencyCode: " +
basePlan.productDetails!.currencyCode.toString());
print("basePlan.productDetails currencySymbol: " +
basePlan.productDetails!.currencySymbol.toString());

purchaseParam = PurchaseParam(
productDetails: basePlan.productDetails!,
);

print("basePlan.purchaseParam : " + purchaseParam.productDetails.id);
print("basePlan.applicationUserName : " +
purchaseParam.applicationUserName.toString());
}

try {
await _inAppPurchasePlatform.buyNonConsumable(
purchaseParam: purchaseParam);
print("Purchase successful!");
} catch (e, stacktrace) {
print("Purchase failed: $e");
print("Stacktrace: $stacktrace");
rethrow; // Preserve the crash for further debugging
}
} catch (e) {
print("Purchase error : $e");

error.value = "Purchase error: $e";
purchasePending.value = false;
isLoading.value = false;

String errorMessage = e.toString();
String displayMessage = '';

// Check if the error contains the specific message
if (errorMessage.contains('storekit_duplicate_product_object')) {
displayMessage =
'There is a pending transaction for the same product identifier. Please either wait for it to be finished or finish it manually using `completePurchase` to avoid edge cases.';
} else {
displayMessage = 'An unexpected purchase error occurred: $errorMessage';
}

Get.snackbar(
"Something went wrong!",
displayMessage,
snackPosition: SnackPosition.BOTTOM,
);
return;
} finally {
print("Purchase finally : ");
isPurchasing.value = false; // Set to false when purchase is done
// isLoading.value = false;
}
}


Подробнее здесь: https://stackoverflow.com/questions/795 ... to-flutter
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «IOS»