Skip to content

Commit 638d0eb

Browse files
authored
Merge pull request #32 from wmorgue/translation_storekit_two
Translation meet StoreKit 2
2 parents eda7ab4 + a5b38be commit 638d0eb

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

.yaspellerrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@
5555
"Sendable",
5656
"unownedExecutor",
5757
"UnownedSerialExecutor",
58+
"inBillingRetryPeriod",
59+
"inGracePeriod",
60+
"AppStore",
61+
"willAutoRenew",
62+
"autoRenewPreference",
63+
"expirationReason",
5864
"workout",
5965
"AppIconBuilder",
6066
"AppsSearchService",

en/meta/articles.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,16 @@
6666
],
6767
"updated_date" : "08.02.2022",
6868
"added_date" : "08.02.2022"
69+
},
70+
"meet-storekit-2" : {
71+
"title" : "StoreKit 2",
72+
"description" : "Apple redesigned the shopping logic and rewrote StoreKit. The great update of this year.",
73+
"category" : "storekit",
74+
"author" : "ivanvorobei",
75+
"keywords" : [
76+
"StoreKit"
77+
],
78+
"updated_date" : "10.02.2022",
79+
"added_date" : "10.02.2022"
6980
}
7081
}

en/tutorials/meet-storekit-2.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
The difficulty of the first version of StoreKit was so overwhelming that it produced a huge number of SAS solutions of varying degrees of lousiness and quality. You definitely know a couple and probably don't know how to work with native StoreKit. That's fine. I don't know too.
2+
3+
The new StoreKit looks like a sip of cold water in the desert. Let's dive in.
4+
5+
![Introducing StoreKit 2](https://cdn.ivanvorobei.by/websites/sparrowcode.io/meet-storekit-2/header.jpg)
6+
7+
## What's new
8+
9+
The models representing purchases and operations on them have been replaced. The names now have no SK prefixes and it is generally intuitive to see which data represent the models. We will not dwell on each one the list is below:
10+
11+
![StoreKit 2 Modes](https://cdn.ivanvorobei.by/websites/sparrowcode.io/meet-storekit-2/models.jpg)
12+
13+
## Request for products and purchase
14+
15+
Before you had to create a `SKProductsRequest` become its delegate, make the request and be sure to keep a strong reference to it so that the system doesn't kill it before it's completed.
16+
17+
Currently:
18+
19+
```swift
20+
// Get products
21+
let storeProducts = try await Product.request(with: identifiers)
22+
23+
// Purchase
24+
let result = try await product.purchase()
25+
switch result {
26+
case .success(let verification):
27+
// handle success
28+
return result
29+
case .userCancelled, .pending:
30+
// handle if needed
31+
default: break
32+
```
33+
34+
Check out the processing statuses. You can add your data to the purchase:
35+
36+
```swift
37+
let result = try await product.purchase(options:[.appAccountToken(yourAppToken))])
38+
```
39+
40+
For communication between accounts and analytics, it's great.
41+
42+
## Subscriptions
43+
44+
If the user has used the trial on one of the group subscriptions, the trial is no longer available to him. There is no easy way to find out if a user is allowed the trial or not. You had to query all transactions and look them up manually. Now it has been simplified to a single line of code.
45+
46+
```swift
47+
static func isEligibleForIntroOffer(for groupID: String) async -> Bool
48+
```
49+
50+
Added auto-renewal subscription state, which was previously only available in the receipt:
51+
52+
- <b>subscribed</b> - subscription is active<br>
53+
- <b>expired</b> - subscription expired<br>
54+
- <b>inBillingRetryPeriod</b> - there was an error when trying to pay<br>
55+
- <b>inGracePeriod</b> - deferred payment by subscription. If your subscription has a grace period enabled and a payment error has occurred, the user will have some more time while the subscription is alive, although the payment has not yet been made. The number of days of the grace period can be from 6 to 16, depending on the length of the subscription itself.<br>
56+
- <b>revoked</b> - access to all subscriptions of this group is denied by the AppStore.
57+
58+
![Subscription information](https://cdn.ivanvorobei.by/websites/sparrowcode.io/meet-storekit-2/subscription-information.jpg)
59+
60+
The `Renewal Info` entity contains information about auto-renewal subscriptions. For example:
61+
62+
- <b>willAutoRenew</b> - key that tells you whether the subscription will automatically renew. If not, it's somewhat likely that the user doesn't plan to continue using the subscription in your app. It's a good time to think about how to hold on to the user.<br>
63+
- <b>autoRenewPreference</b> - The ID of the subscription to which the auto-renewal will happen. You can check if the user has made a downgrade and wants to use the cheaper version of your subscription. In this case, you can try to offer him a discount and keep them on the more premium version if you want to.<br>
64+
- <b>expirationReason</b> - here you can read more about the reasons for the expiration of a subscription.
65+
66+
There are even more goodies. Purchases are restored automatically, async support, improved API with naming functions and models, subscription status, availability of the offerer. Looks like the beginning of death for SAS solutions (it's more complicated there, but the update is still a killer).
67+
68+
## Backwards compatibility
69+
70+
Purchases from the first version will work in the second. The new StoreKit is available only since iOS 15. Most projects for some reason keep support for iOS 6, so the real use we will see only in indie projects.
71+
72+
Thanks to author of the [article](https://habr.com/ru/post/563280/), find out more in the original Russian version.

0 commit comments

Comments
 (0)