Question

Purchases.purchasePackage() doesn't return


Userlevel 1
Badge +5

Hello,

I’m using purchases-flutter 4.1.2 (latest at the moment). I’ve set up the entitlements, offerings, products as well as packages as guided in https://docs.revenuecat.com/docs/ios-products

I can get the offerrings and display the packages correctly.

But when I make a call to `Purchases.purchasePackage()` to purchase a package, the call just hangs and doesn’t return at all.

Here’s my dependency list:

```

environment:
  sdk: ">=2.17.5 <3.0.0"

dependencies:
  another_flushbar: ^1.10.23
  awesome_notifications: ^0.6.21
  bloc: ^8.0.2
  cached_network_image: ^3.1.0
  cloud_firestore: ^3.4.4
  easy_localization: ^3.0.0
  easy_localization_loader: ^1.0.0
  equatable: ^2.0.3
  firebase_analytics: ^9.3.1
  firebase_auth: ^3.6.3
  firebase_core: ^1.20.1
  firebase_messaging: ^12.0.2
  flow_builder: ^0.0.2
  flutter:
    sdk: flutter
  flutter_bloc: ^8.0.1
  flutter_onboard: ^2.0.0
  flutter_platform_widgets: ^2.0.0
  flutter_svg: ^1.0.0
  flutter_typeahead: ^4.0.0
  formz: ^0.4.0
  google_fonts: ^3.0.1
  grouped_list: ^5.1.2
  hydrated_bloc: ^9.0.0-dev
  lint: ^1.0.0
  meta: ^1.7.0
  path_provider: ^2.0.2
  pattern_formatter: ^2.0.0
  provider: ^6.0.1
  rxdart: ^0.27.4
  scrollable_positioned_list: ^0.3.2
  shared_preferences: ^2.0.6
  synchronized: ^3.0.0
  toggle_switch: ^2.0.1
  crypto: ^3.0.2
  flutter_keyboard_visibility: ^5.3.0
  uuid: ^3.0.4
  intl: ^0.17.0
  characters: ^1.2.0
  sentry_flutter: ^6.1.2
  sign_in_with_apple: ^4.0.0
  flutter_slidable: ^1.1.0
  internet_connection_checker: ^0.0.1+3
  device_info_plus: ^4.0.0
  package_info_plus: ^1.3.0
  timeago: ^3.2.1
  local_auth: ^2.1.0
  secure_application: ^3.8.0
  purchases_flutter: ^4.1.2
  modal_progress_hud_nsn: ^0.3.0

dev_dependencies:
  bloc_test: ^9.0.2
  flutter_launcher_icons: "^0.9.2"
  flutter_lints: ^2.0.0
  flutter_test:
    sdk: flutter
  logger: null
  mocktail: ^0.3.0
```

 

And this is the debug log when I try to load the screen and trigger the purchasePackage function:

```

2022-08-22 19:49:37.665783+0700 Runner[8559:16612850] [Purchases] - DEBUG: ℹ️ Vending Offerings from cache

2022-08-22 19:49:37.669501+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.679191+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.679445+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.679716+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.679962+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.680299+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.680496+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.680679+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.682355+0700 Runner[8559:16612850] [Purchases] - DEBUG: ℹ️ Offerings cache is stale, updating from network in foreground

2022-08-22 19:49:37.682468+0700 Runner[8559:16612850] [Purchases] - DEBUG: 😻 Offerings updated from network.

2022-08-22 19:49:37.683176+0700 Runner[8559:16770060] [Purchases] - DEBUG: ℹ️ GetOfferingsOperation: Started

2022-08-22 19:49:37.683405+0700 Runner[8559:16770060] [Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request GET subscribers/4R9IChuPBJMxLDVbIZfip7J5AV12/offerings

2022-08-22 19:49:37.685568+0700 Runner[8559:16770060] [Purchases] - DEBUG: ℹ️ API request started: GET /v1/subscribers/4R9IChuPBJMxLDVbIZfip7J5AV12/offerings

2022-08-22 19:49:38.627514+0700 Runner[8559:16776577] [boringssl] boringssl_metrics_log_metric_block_invoke(151) Failed to log metrics

2022-08-22 19:49:38.906210+0700 Runner[8559:16770060] [Purchases] - DEBUG: ℹ️ API request completed: GET /v1/subscribers/4R9IChuPBJMxLDVbIZfip7J5AV12/offerings 304

2022-08-22 19:49:38.908744+0700 Runner[8559:16770060] [Purchases] - DEBUG: ℹ️ GetOfferingsOperation: Finished

2022-08-22 19:49:38.908827+0700 Runner[8559:16776577] [Purchases] - DEBUG: ℹ️ Skipping products request because products were already cached. products: ["myapp_45000_1m_1w0", "myapp_499000_1y_2w0"]

2022-08-22 19:49:38.909315+0700 Runner[8559:16770060] [Purchases] - DEBUG: ℹ️ Serial request done: GET subscribers/4R9IChuPBJMxLDVbIZfip7J5AV12/offerings, 0 requests left in the queue

2022-08-22 19:49:40.950981+0700 Runner[8559:16612850] [Purchases] - DEBUG: ℹ️ Vending Offerings from cache

2022-08-22 19:49:40.951716+0700 Runner[8559:16612850] [Purchases] - INFO: 💰 Purchasing Product 'myapp_45000_1m_1w0' from package in Offering 'default'

2022-08-22 19:49:40.954935+0700 Runner[8559:16612850] [Purchases] - DEBUG: ℹ️ PaymentQueue updatedTransaction: myapp_45000_1m_1w0 0

2022-08-22 19:49:40.955110+0700 Runner[8559:16612850] [Purchases] - WARN: 🍎‼️ There is a problem with the SKPaymentTransaction missing a transaction date - this is an issue with the App Store. Unix Epoch will be used instead.

Transactions in the backend and in webhooks are unaffected and will have the correct timestamps. This is a bug in StoreKit 1. To prevent running into this issue on devices running iOS 15+, watchOS 8+, macOS 12+, and tvOS 15+, you can set `usesStoreKit2IfAvailable` to true when calling `configure`.

2022-08-22 19:49:40.955829+0700 Runner[8559:16612850] [Purchases] - WARN: 🍎‼️ There is a problem with the SKPaymentTransaction missing a transaction identifier - this is an issue with the App Store.Transactions in the backend and in webhooks are unaffected and will have the correct identifier. This is a bug in StoreKit 1. To prevent running into this issue on devices running iOS 15+, watchOS 8+, macOS 12+, and tvOS 15+, you can set `usesStoreKit2IfAvailable` to true when calling `configure`.

objc[8559]: Class _PathPoint is implemented in both /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore (0x12e16ebb8) and /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/TextInputUI.framework/TextInputUI (0x14c305210). One of the two will be used. Which one is undefined.

objc[8559]: Class _PointQueue is implemented in both /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore (0x12e16eb90) and /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/TextInputUI.framework/TextInputUI (0x14c305238). One of the two will be used. Which one is undefined.

2022-08-22 19:51:30.917345+0700 Runner[8559:16778768] [boringssl] boringssl_metrics_log_metric_block_invoke(151) Failed to log metrics

```


42 replies

Userlevel 3
Badge +3

Thanks for opening this question with more details. One quick question. Does this happen to you only on iOS? Have you tried on an Android device?

Are you running on a physical device or a simulator?

Thanks!

Userlevel 1
Badge +5

Hi @Cesar, I’m experiencing this on iOS only. I haven’t been able to test this on Android yet.

I tried on both physical iPhone and simulator, both stuck after tapping the package (which triggers the purchase function).

Badge +1

Getting same error on IOS Device at the same place as the poster (also not using android):

[Purchases] - WARN: 🍎‼️ There is a problem with the SKPaymentTransaction missing a transaction date - this is an issue with the App Store. Unix Epoch will be used instead.

Transactions in the backend and in webhooks are unaffected and will have the correct timestamps. This is a bug in StoreKit 1. To prevent running into this issue on devices running iOS 15+, watchOS 8+, macOS 12+, and tvOS 15+, you can set `usesStoreKit2IfAvailable` to true when calling `configure`.

 

I’m using flutter and had the following code:

await Purchases.setup("blahblahblah",    appUserId: LoginUser.userUid);

which was showing as deprecated.

So I updated to the new format found on the revenuecat website:

 await Purchases.configure(     PurchasesConfiguration("blahblahblah")       ..appUserID = LoginUser.userUid

and got the above error. 

Reverted back to the deprecated code and its working ok.

Userlevel 1
Badge +5

This looks related to my issue: https://github.com/RevenueCat/purchases-flutter/issues/431

Badge +3

I am having this same issue. 

Userlevel 1
Badge +5

Hi @Cesar do you need more information to reproduce this?

Userlevel 3
Badge +3

Hi @Thanh !

We are trying to reproduce the issue. As @Andy suggested in the GitHub issue, we're currently preparing release 4.2.0, which will get rid of the warnings you see on the console and might also fix the issues, since it uses StoreKit 2 APIs under the hood, and they seem to be more reliable.

Are you also handling errors? Do you see any PlaformException at all?

 

Userlevel 1
Badge +5

My mistake, I didn’t add the Appstore shared secret to Revenuecat. After I did, the function doesn’t hang on my real iPhone, but it still hangs on the iOS simulator.

Userlevel 1
Badge +5

@Cesar Thank you for the update. I’m eager to try out the new release ^^

Are you also handling errors? Do you see any PlaformException at all?

 

Yes I have try & catch block to handle the exception but there’s no exception thrown at all because the function purchasePackage doesn’t return.

Here’s my code:

                              try {
final CustomerInfo customerInfo = await Purchases.purchasePackage(packages![selectedPackageIndex!]);
final isPremium = customerInfo.entitlements.all[REVENUE_CAT_DEFAULT_ENTITLEMENT]?.isActive ?? false;
if (isPremium) {
// Display flashbar and go back
}
} on PlatformException catch (e) {
final errorCode = PurchasesErrorHelper.getErrorCode(e);
if (errorCode != PurchasesErrorCode.purchaseCancelledError) {
print(e);
}
await showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text("Error"),
content: SingleChildScrollView(
child: ListBody(
children: [
Text(e.message.toString()),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('Ok'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
),
);
}
setState(() {
isLoading = false;
});
}

 

Userlevel 3
Badge +3

but it still hangs on the iOS simulator.

 

That’s probably because iOS simulators require a special configuration using StoreKit config files. You can read more about that in this article in our docs https://docs.revenuecat.com/docs/apple-app-store#ios-14-only-testing-on-the-simulator

Do you mind giving that a try and report back?

The fact that purchasePackage doesn’t return is indeed a weird one, because I would expect it would throw an error indicating there’s a problem with your configuration in RevenueCat. We’ll look into that

Userlevel 3
Badge +3

@Thanh Did you figure this out? We couldn’t reproduce purchasePackage not returning. We have identified an issue with purchaseProduct, but that seems unrelated

Userlevel 1
Badge +5

Hi Cesar, I haven’t tested on simulator as you said (using storekit config file) yet. Other than that the function does return on real iphones after setting Appstore shared secret.

Badge +1

 

Hi Cesar, I haven’t tested on simulator as you said (using storekit config file) yet. Other than that the function does return on real iphones after setting Appstore shared secret.

 

Hi @Thanh, when you tried this on physical device, are you using sandbox tester account or the real apple account ?

Userlevel 1
Badge +5

Hi @Chaitanya 

I tested with a sandbox account. 
Also tried with a real apple account and it was good.

Userlevel 1
Badge +4

Any update on this? I’m getting this error with the latest SDK with React Native

Badge +3

Yes same warnings with React Native on Xcode debug log, building in release mode.

using react-native-purchases : 5.14.0 (updating from 4.4.1 who has no warning)

 

2023-05-05 11:20:45.154377+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154609+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154706+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154791+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154908+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.155013+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.155075+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.155140+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

 

Badge +1

Yes same warnings with React Native on Xcode debug log, building in release mode.

using react-native-purchases : 5.14.0 (updating from 4.4.1 who has no warning)

 

2023-05-05 11:20:45.154377+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154609+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154706+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154791+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154908+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.155013+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.155075+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.155140+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

 

I too am getting this on my flutter project

Badge +3

I’m also getting “

WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.”

 

 

Warning repeatedly in the console on one of my projects, I’m using 5.16

Badge +1

I used purchases_flutter: 5.2.3 and the same issue

[store_kit] WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

People, let's improve our contact with the tool here. Haven't solved this problem yet?

Badge +1

This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
Still saw on purchases_flutter: 5.4.0

Badge +2

I get the same warning:

This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
 

purchases_flutter: 5.4.0

Badge +2

@Cesar could you please support us here?

Badge +2

In my case this issue appears only on iOS. On Android everything seems to work fine. Now on iOS, I have two subscriptions. An annual and a monthly. The annual one, works fine. But when a user chooses the monthly, I’m getting the following warning:

This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

 

Userlevel 3
Badge +3

Does your `purchasePackage` function also not return? Is anything not working?

Those warnings are just indicating that the product’s productType will be `nonConsumable` because it can’t be determined and that should be accessing `productCategory` instead, so they should be safe to ignore. I think we will probably update that log since it’s clear it’s too noisy.

Reply