Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate misnamed purchase(params) function in Obj-C #4645

Merged
merged 2 commits into from
Jan 10, 2025

Conversation

fire-at-will
Copy link
Contributor

@fire-at-will fire-at-will commented Jan 9, 2025

Motivation

The purchase(_ params: PurchaseParams, completion: @escaping PurchaseCompletedBlock) was mistakenly exposed to Objective-C with the name params in #4485.

Description

This PR deprecates that existing params name in Objective-C (@objc(params:withCompletion:)) and replaces it with purchaseWithParams (@objc(purchaseWithParams:completion:)).

Implementation Details

Swift doesn't support deprecating only an Objective-C selector. You need to create a second Swift function with the correct @objc selector and ensure that the Swift function names don't conflict. This isn't ideal because it adds an extra deprecated function to the Swift API, but it gets the job done.

So to accomplish this, this PR renames the existing Swift function with the incorrect @objc selector to purchaseWithParams and marks it as deprecated.

Old Obj-C API

[p params:purchaseParams withCompletion:^(RCStoreTransaction *t, RCCustomerInfo *i, NSError *error, BOOL userCancelled) { }];

New Obj-C API

[p purchaseWithParams:purchaseParams completion:^(RCStoreTransaction *t, RCCustomerInfo *i, NSError *error, BOOL userCancelled) { }];

@fire-at-will fire-at-will added the pr:fix A bug fix label Jan 9, 2025
@fire-at-will
Copy link
Contributor Author

@RCGitBot please test

@fire-at-will fire-at-will self-assigned this Jan 9, 2025
#if !ENABLE_CUSTOM_ENTITLEMENT_COMPUTATION
if (@available(iOS 18.0, macOS 15.0, tvOS 18.0, watchOS 11.0, visionOS 2.0, *)) {
RCPurchaseParams *packageParams;
[p params:packageParams withCompletion:^(RCStoreTransaction *t, RCCustomerInfo *i, NSError *error, BOOL userCancelled) { }];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moves the old call to the deprecated section

@fire-at-will fire-at-will marked this pull request as ready for review January 9, 2025 20:20
@fire-at-will fire-at-will requested review from aboedo, MarkVillacampa and a team January 9, 2025 20:20
@fire-at-will fire-at-will merged commit dc3de11 into main Jan 10, 2025
10 checks passed
@fire-at-will fire-at-will deleted the deprecate-objc-param-function branch January 10, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:fix A bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants