Skip to content

[in_app_purchase] In StoreKit2, the quantity of SK2ProductPurchaseOptionsMessage does not work. #171570

Closed
flutter/packages
#9698

Description

@AmazyConch

What package does this bug report belong to?

in_app_purchase

What target platforms are you seeing this bug on?

iOS

Have you already upgraded your packages?

Yes

Dependency versions

No response

Steps to reproduce

In InAppPurchasePlugin+StoreKit2.swift file:

...
var purchaseOptions: Set<Product.PurchaseOption> = []
if let appAccountToken = options?.appAccountToken,
  let accountTokenUUID = UUID(uuidString: appAccountToken)
{
  purchaseOptions.insert(.appAccountToken(accountTokenUUID))
}
if let quantity = options?.quantity {
    purchaseOptions.insert(.quantity(Int(quantity)))
}
if #available(iOS 17.4, macOS 14.4, *) {
  if let promotionalOffer = options?.promotionalOffer {
    purchaseOptions.insert(
      .promotionalOffer(
        offerID: promotionalOffer.promotionalOfferId,
        signature: promotionalOffer.promotionalOfferSignature.convertToSignature
      )
    )
  }
}
if #available(iOS 18.0, macOS 15.0, *) {
  if let winBackOfferId = options?.winBackOfferId,
    let winBackOffer = product.subscription?.winBackOffers.first(where: {
      $0.id == winBackOfferId
    })
  {
    purchaseOptions.insert(.winBackOffer(winBackOffer))
  }
}
let result = try await product.purchase(options: purchaseOptions)
...

The .quantity was not inserted into purchaseOptions, so I am unable to handle bulk purchase scenarios.

Expected results

Add

if let quantity = options?.quantity {
    purchaseOptions.insert(.quantity(Int(quantity)))
}

to the purchase method.

On the Flutter side:
Add quantity: purchasedQuantity, to the convertFromPigeon method.

Actual results

the quantity does not work.

Code sample

Leave a comment

Screenshots or Videos

No response

Logs

No response

Flutter Doctor output

Leave a comment

Activity

  1. tirth-patel-nc commented on Jul 3, 2025

    @tirth-patel-nc
    Member

    thanks for the report. labeling this as a new proposal. feel free to submit a PR.

    I noticed a related request in a different context, but found the quantity handling code already present in #169646.

  2. added
    packageflutter/packages repository. See also p: labels.
    platform-iosiOS applications specifically
    team-iosOwned by iOS platform team
    c: proposalA detailed proposal for a change to Flutter
    and removed
    in triagePresently being triaged by the triage team
    on Jul 3, 2025
  3. nikunjrCybage commented on Jul 8, 2025

    @nikunjrCybage

    @tirth-patel-nc I’d like to contribute a fix for this. Just confirming — can we go ahead and create a PR to add proper support for the quantity parameter in StoreKit 2 by updating both the Swift and Dart sides accordingly?

  4. tirth-patel-nc commented on Jul 8, 2025

    @tirth-patel-nc
    Member

    I'm not aware of the exact changes. you may check the relevant discord channel linked in the contribution guide for more details.

  5. added
    P2Important issues not at the top of the work list
    triaged-iosTriaged by iOS platform team
    on Jul 17, 2025
  6. vashworth commented on Jul 17, 2025

    @vashworth
    Contributor

    @tirth-patel-nc I’d like to contribute a fix for this. Just confirming — can we go ahead and create a PR to add proper support for the quantity parameter in StoreKit 2 by updating both the Swift and Dart sides accordingly?

    We welcome PRs! Here's the contributor guide to get you started: https://github.com/flutter/flutter/blob/master/CONTRIBUTING.md

  7. added a commit that references this issue on Aug 12, 2025
  8. added a commit that references this issue on Aug 12, 2025
  9. added a commit that references this issue on Aug 14, 2025
  10. added a commit that references this issue on Aug 19, 2025
  11. github-actions commented on Aug 26, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  12. locked as resolved and limited conversation to collaborators on Aug 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: proposalA detailed proposal for a change to Flutterp: in_app_purchasePlugin for in-app purchasepackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions