{
    "componentChunkName": "component---src-templates-flutter-blog-post-js",
    "path": "/flutter-blog/storekit-2-what-has-changed/",
    "result": {"data":{"prismicFlutterPost":{"_previewable":"YXJ0RBEAACAAXN6L","uid":"storekit-2-what-has-changed","first_publication_date":"2021-10-22T08:50:56+0000","last_publication_date":"2021-10-22T10:05:54+0000","lang":"en-us","data":{"rich_text":{"text":"With StoreKit 2, Apple has released at the WWDC21 a much-improved version of the unwieldy framework we’ve all had to deal with so far. According to Apple, the main keys to StoreKit 2 are: It’s designed Swift-first Powerful new APIs Simple and secure transactions Customer support Testing Support So let’s take a brief look to what has changed! StoreKit 2 Swiftyness As already mentioned before, StoreKit 2 has been designed with a Swift-first mindset and takes all the advantages like async & await Swift has to offer. This also means that StoreKit 2 is only available for iOS 15 and upwards. StoreKit 2 vs StoreKit 1 So what’s so swifty about StoreKit 2? to answer the question, let’s just examine the differences between the old and the new version of StoreKit! StoreKit 1 To fetch products in StoreKit 1 you had to do something like this: let request = SKProductsRequest(productIdentifiers: Set([\"linkfive.subscription.premium\", \"linkfive.subscription.light\"]))\nrequest.delegate = self\nrequest.start() extension ExamplePurchases: SKProductsRequestDelegate {\n\n    public func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {\n        let products = response.products\n        /// Do something with the products\n    }\n\n    public func request(_ request: SKRequest, didFailWithError error: Error) {\n        /// Do something with the error\n    }\n} So what you basically do, is requesting the products with the given ids and attach the SKProductsRequestDelegate which receives an SKProductsResponse object with the products in it when the request completes. Yikes! StoreKit 2 Now let’s take a look at the StoreKit 2 way: func fetchProducts() async throws -> [Product] {\n    let products = try await Product.request(with: Set([\"linkfive.subscription.premium\", \"linkfive.subscription.light\"]))\n    return products\n} Et voilà! That’s it! No delegate foo anymore, just straight up async/await sugar. If you also look at the other APIs, the new syntax runs through like a red thread. This definitely makes the development much easier and faster than before! The new APIs Refunds Developers are now able to add a “Request refund” button to their apps. A tap on the button opens another form where customers can request a refund with some additional information. The request does not go to the developers themselves, but to Apple, who is going to review the refund. Invoice / Refunds Lookup These are basically API’s which return the transaction / refund history for the given customer_order_id. Conclusion StoreKit 2 is a huge step into the right direction. It’s API is much cleaner, more understandable and in all ways better to use. It’s definitely a great gift for all the developers out there! But if you would like to have more control over your subscriptions and manage them properly, you are at the right place! LinkFive will help you to drive your subscription game up. Feel free to sign up now and enjoy the rich advantages we offer to you.","raw":[{"type":"paragraph","text":"With StoreKit 2, Apple has released at the WWDC21 a much-improved version of the unwieldy framework we’ve all had to deal with so far.","spans":[]},{"type":"paragraph","text":"According to Apple, the main keys to StoreKit 2 are:","spans":[]},{"type":"list-item","text":"It’s designed Swift-first","spans":[]},{"type":"list-item","text":"Powerful new APIs","spans":[]},{"type":"list-item","text":"Simple and secure transactions","spans":[]},{"type":"list-item","text":"Customer support","spans":[]},{"type":"list-item","text":"Testing Support","spans":[]},{"type":"paragraph","text":"So let’s take a brief look to what has changed!","spans":[]},{"type":"heading2","text":"StoreKit 2 Swiftyness","spans":[]},{"type":"paragraph","text":"As already mentioned before, StoreKit 2 has been designed with a Swift-first mindset and takes all the advantages like async & await Swift has to offer. This also means that StoreKit 2 is only available for iOS 15 and upwards.","spans":[]},{"type":"heading3","text":"StoreKit 2 vs StoreKit 1","spans":[]},{"type":"paragraph","text":"So what’s so swifty about StoreKit 2? to answer the question, let’s just examine the differences between the old and the new version of StoreKit!","spans":[]},{"type":"heading4","text":"StoreKit 1","spans":[]},{"type":"paragraph","text":"To fetch products in StoreKit 1 you had to do something like this:","spans":[{"start":21,"end":31,"type":"strong"}]},{"type":"preformatted","text":"let request = SKProductsRequest(productIdentifiers: Set([\"linkfive.subscription.premium\", \"linkfive.subscription.light\"]))\nrequest.delegate = self\nrequest.start()","spans":[]},{"type":"preformatted","text":"extension ExamplePurchases: SKProductsRequestDelegate {\n\n    public func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {\n        let products = response.products\n        /// Do something with the products\n    }\n\n    public func request(_ request: SKRequest, didFailWithError error: Error) {\n        /// Do something with the error\n    }\n}","spans":[]},{"type":"paragraph","text":"So what you basically do, is requesting the products with the given ids and attach the SKProductsRequestDelegate which receives an SKProductsResponse object with the products in it when the request completes. Yikes!","spans":[]},{"type":"heading4","text":"StoreKit 2","spans":[]},{"type":"paragraph","text":"Now let’s take a look at the StoreKit 2 way:","spans":[{"start":29,"end":39,"type":"strong"}]},{"type":"preformatted","text":"func fetchProducts() async throws -> [Product] {\n    let products = try await Product.request(with: Set([\"linkfive.subscription.premium\", \"linkfive.subscription.light\"]))\n    return products\n}","spans":[]},{"type":"paragraph","text":"Et voilà! That’s it! No delegate foo anymore, just straight up async/await sugar. If you also look at the other APIs, the new syntax runs through like a red thread. This definitely makes the development much easier and faster than before!","spans":[{"start":63,"end":74,"type":"strong"}]},{"type":"heading3","text":"The new APIs","spans":[]},{"type":"heading4","text":"Refunds","spans":[]},{"type":"paragraph","text":"Developers are now able to add a “Request refund” button to their apps. A tap on the button opens another form where customers can request a refund with some additional information. The request does not go to the developers themselves, but to Apple, who is going to review the refund.","spans":[]},{"type":"heading4","text":"Invoice / Refunds Lookup","spans":[]},{"type":"paragraph","text":"These are basically API’s which return the transaction / refund history for the given customer_order_id.","spans":[]},{"type":"heading3","text":"Conclusion","spans":[]},{"type":"paragraph","text":"StoreKit 2 is a huge step into the right direction. It’s API is much cleaner, more understandable and in all ways better to use. It’s definitely a great gift for all the developers out there!","spans":[]},{"type":"paragraph","text":"But if you would like to have more control over your subscriptions and manage them properly, you are at the right place! LinkFive will help you to drive your subscription game up. Feel free to sign up now and enjoy the rich advantages we offer to you.","spans":[]}]},"title":{"text":"StoreKit 2 - What has changed?"},"hero_image":{"alt":"Introducing StoreKit 2","localFile":{"childImageSharp":{"fluid":{"aspectRatio":2.150537634408602,"src":"/static/bc730c133a017335e0f02b031b7956df/ee604/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.png","srcSet":"/static/bc730c133a017335e0f02b031b7956df/69585/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.png 200w,\n/static/bc730c133a017335e0f02b031b7956df/497c6/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.png 400w,\n/static/bc730c133a017335e0f02b031b7956df/ee604/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.png 800w,\n/static/bc730c133a017335e0f02b031b7956df/f3583/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.png 1200w,\n/static/bc730c133a017335e0f02b031b7956df/5707d/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.png 1600w,\n/static/bc730c133a017335e0f02b031b7956df/bbee5/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.png 1800w","sizes":"(max-width: 800px) 100vw, 800px","base64":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAIAAAC9o5sfAAAACXBIWXMAAAsTAAALEwEAmpwYAAABTElEQVQoz2NgxAqYmBgYGJg4uZmYmRgZQHysqhhw6RRwDRBefZ8xYw4zBy8jAwMjExMRmllYQFqdQuSv/e988Lfoyn/57E0gVzARYzMLG8ie+EbW3f/z9n9S7v/NkfuCiZ0HJIjheAYmNMDKysTAwGznzrL3K9vU/5zN/9kSFzHBlDEzMyOrBdnMDAYsYABisLIxMTCwWtuwLzjNHNrIyMTIApJlZWFhYWCAuhTsESYGNjY2CAciwcrKysDAwMLKBgk2LjZWfl4+uCw3Nw87OzsHBwc/Pz9Il6GhYWpqamxsXGRkVEZGZl5evp+ff3x8QnJqWmhYhKe3b0FhUUREZGxsXGpqWll5eWJikqWlpYuLK8g8MTExTU1NdXV1LS1tU1NTExMTIyMjHTAICg5WUVHV0NDQ09PT0dExNjHR0dHV0NCQlZVVVFQE2gwAHHw9iA9FUZoAAAAASUVORK5CYII=","srcSetWebp":"/static/bc730c133a017335e0f02b031b7956df/61e93/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.webp 200w,\n/static/bc730c133a017335e0f02b031b7956df/1f5c5/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.webp 400w,\n/static/bc730c133a017335e0f02b031b7956df/58556/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.webp 800w,\n/static/bc730c133a017335e0f02b031b7956df/99238/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.webp 1200w,\n/static/bc730c133a017335e0f02b031b7956df/7c22d/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.webp 1600w,\n/static/bc730c133a017335e0f02b031b7956df/685a2/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.webp 1800w"},"gatsbyImageData":{"layout":"fullWidth","backgroundColor":"#080808","images":{"fallback":{"src":"/static/bc730c133a017335e0f02b031b7956df/d7441/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.png","srcSet":"/static/bc730c133a017335e0f02b031b7956df/2a360/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.png 750w,\n/static/bc730c133a017335e0f02b031b7956df/c7768/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.png 1080w,\n/static/bc730c133a017335e0f02b031b7956df/ac867/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.png 1366w,\n/static/bc730c133a017335e0f02b031b7956df/d7441/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.png 1800w","sizes":"100vw"},"sources":[{"srcSet":"/static/bc730c133a017335e0f02b031b7956df/be179/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.webp 750w,\n/static/bc730c133a017335e0f02b031b7956df/1eb10/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.webp 1080w,\n/static/bc730c133a017335e0f02b031b7956df/e34d1/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.webp 1366w,\n/static/bc730c133a017335e0f02b031b7956df/df00f/1a5d2b60-e5e5-4a02-b94a-d6ee72548d9a_Bildschirmfoto%2B2021-10-22%2Bum%2B10.24.17.webp 1800w","type":"image/webp","sizes":"100vw"}]},"width":1,"height":0.4666666666666667}}},"dimensions":{"width":1800,"height":840}},"author_name":{"text":"Nini"},"meta_description":{"text":"StoreKit 2 - What has changed? Apple introduced StoreKit 2 for in app purchases. What is new?\b"},"meta_title":{"text":"StoreKit 2 - What has changed?"}}}},"pageContext":{"id":"b9c40278-fca7-565e-9331-add50b4621b6","uid":"storekit-2-what-has-changed","lang":"en-us","type":"flutter_post","url":"/flutter-blog/storekit-2-what-has-changed/"}},
    "staticQueryHashes": []}