Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ......
Transcript of Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ......
![Page 1: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/1.jpg)
© 2014 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
#WWDC14
Optimizing In-App PurchasesUsing StoreKit
Session 303James Wilson Software Engineering
Services
![Page 2: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/2.jpg)
StoreKit
![Page 3: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/3.jpg)
StoreKit Features
![Page 4: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/4.jpg)
StoreKit Features
In-App Purchases • Consumables and non-consumable
• Subscriptions
![Page 5: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/5.jpg)
StoreKit Features
In-App Purchases • Consumables and non-consumable
• Subscriptions
Store Product Sheet
![Page 6: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/6.jpg)
StoreKit Features
In-App Purchases • Consumables and non-consumable
• Subscriptions
Store Product Sheet
Receipt renewal
![Page 7: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/7.jpg)
What’s New
![Page 8: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/8.jpg)
What’s New
StoreKit product sheet supports affiliate program
![Page 9: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/9.jpg)
What’s New
StoreKit product sheet supports affiliate program
New transaction state—Deferred
• Ask to Buy feature of Family Sharing
![Page 10: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/10.jpg)
Deferred Transaction StateSKPaymentTransactionStateDeferred
![Page 11: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/11.jpg)
Deferred Transaction StateSKPaymentTransactionStateDeferred
The payment is neither purchased nor failed, yet
![Page 12: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/12.jpg)
Deferred Transaction StateSKPaymentTransactionStateDeferred
The payment is neither purchased nor failed, yet • Further update will be received
![Page 13: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/13.jpg)
Deferred Transaction StateSKPaymentTransactionStateDeferred
The payment is neither purchased nor failed, yet • Further update will be received
• Indeterminate time
![Page 14: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/14.jpg)
Deferred Transaction StateSKPaymentTransactionStateDeferred
The payment is neither purchased nor failed, yet • Further update will be received
• Indeterminate time
Must allow the user to continue to use the app
![Page 15: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/15.jpg)
Deferred Transaction StateSKPaymentTransactionStateDeferred
The payment is neither purchased nor failed, yet • Further update will be received
• Indeterminate time
Must allow the user to continue to use the app
• Repurchasing the item is allowed
![Page 16: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/16.jpg)
Deferred Transaction StateSKPaymentTransactionStateDeferred
The payment is neither purchased nor failed, yet • Further update will be received
• Indeterminate time
Must allow the user to continue to use the app
• Repurchasing the item is allowed
• Let StoreKit handle the interaction
![Page 17: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/17.jpg)
Deferred Transaction StateAsk to Buy
Child Parent
![Page 18: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/18.jpg)
Deferred Transaction StateAsk to Buy
Child ParentAttempts In-App
Purchase
![Page 19: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/19.jpg)
Deferred Transaction StateAsk to Buy
Child ParentAttempts In-App
PurchaseNotified of request
![Page 20: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/20.jpg)
Deferred Transaction StateAsk to Buy
Child ParentAttempts In-App
PurchaseNotified of request
SKPaymentTransactionStateDeferred
![Page 21: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/21.jpg)
Deferred Transaction StateAsk to Buy
Child Parent
![Page 22: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/22.jpg)
Deferred Transaction StateAsk to Buy
Child ParentApproves or declines
![Page 23: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/23.jpg)
Deferred Transaction StateAsk to Buy
Child ParentTransaction updated Approves or declines
![Page 24: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/24.jpg)
Deferred Transaction StateAsk to Buy
Child ParentTransaction updated Approves or declines
SKPaymentTransactionStatePurchased SKPaymentTransactionStateFailed
![Page 25: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/25.jpg)
Optimizing In-App Purchases
![Page 26: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/26.jpg)
In-App Purchase Process
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
![Page 27: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/27.jpg)
In-App Purchase Process
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
Load In-AppIdentifiers
![Page 28: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/28.jpg)
In-App Purchase Process
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
FetchProduct Info
![Page 29: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/29.jpg)
In-App Purchase Process
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
ShowIn-App UI
![Page 30: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/30.jpg)
In-App Purchase Process
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
MakePurchase
![Page 31: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/31.jpg)
In-App Purchase Process
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
ProcessTransaction
![Page 32: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/32.jpg)
In-App Purchase Process
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
Make Asset Available
![Page 33: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/33.jpg)
In-App Purchase Process
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
FinishTransaction
![Page 34: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/34.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
FinishTransaction
Danger Zones
In-App Purchase Process
![Page 35: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/35.jpg)
User Interaction
![Page 36: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/36.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
![Page 37: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/37.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
ShowIn-App UI
![Page 38: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/38.jpg)
Product Identifier
![Page 39: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/39.jpg)
Product Identifier
Options for storing the list of product identifiers
![Page 40: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/40.jpg)
Product Identifier
Options for storing the list of product identifiers• Baked-in product identifier
![Page 41: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/41.jpg)
Product Identifier
Options for storing the list of product identifiers• Baked-in product identifier
• Fetch from server
![Page 42: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/42.jpg)
Product Identifier
Options for storing the list of product identifiers• Baked-in product identifier
• Fetch from server
- Cache strategy
![Page 43: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/43.jpg)
Product Identifier
Options for storing the list of product identifiers• Baked-in product identifier
• Fetch from server
- Cache strategy
- Reliability
![Page 44: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/44.jpg)
![Page 45: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/45.jpg)
![Page 46: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/46.jpg)
Not the way to start an In-App Purchase
![Page 47: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/47.jpg)
Product Information
Fetch the product information using StoreKit
!
SKProductsRequest* request = [[SKProductsRequest alloc]
initWithProductIdentifiers:identifierSet];
![Page 48: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/48.jpg)
Product Information
Fetch the product information using StoreKit
!
SKProductsRequest* request = [[SKProductsRequest alloc]
initWithProductIdentifiers:identifierSet];
Anticipate the presentation
![Page 49: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/49.jpg)
Product Information
Fetch the product information using StoreKit
!
SKProductsRequest* request = [[SKProductsRequest alloc]
initWithProductIdentifiers:identifierSet];
Anticipate the presentation• Fetch product info just-ahead-of-time
![Page 50: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/50.jpg)
SKProduct Object
SKProduct properties • Localized title and description
• Price and locale
• Content size and version (hosted)
![Page 51: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/51.jpg)
Price and Currency
![Page 52: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/52.jpg)
Price and Currency
1.234,56 €
![Page 53: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/53.jpg)
Price and Currency
1.234,56 €
£1,234.56
![Page 54: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/54.jpg)
Price and Currency
1.234,56 €
£1,234.56
€1,234.56
![Page 55: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/55.jpg)
Price and Currency
1.234,56 €
£1,234.56
€1,234.56
1.234,56 kn
![Page 56: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/56.jpg)
Price and Currency
1.234,56 €
£1,234.56
€1,234.56
1.234,56 kn
R$ 1.234,56
![Page 57: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/57.jpg)
Price and Currency
1.234,56 €
£1,234.56
€1,234.56
1.234,56 kn
R$ 1.234,56
฿1,234.56
![Page 58: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/58.jpg)
Price and Currency
1.234,56 €
£1,234.56
€1,234.56
1.234,56 kn
R$ 1.234,56
฿1,234.56
$1,234.56
![Page 59: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/59.jpg)
Price and Currency
Showing localized price
![Page 60: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/60.jpg)
Price and Currency
Showing localized price
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
![Page 61: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/61.jpg)
Price and Currency
Showing localized price
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
![Page 62: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/62.jpg)
Price and Currency
Showing localized price
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];[numberFormatter setLocale:product.priceLocale];
![Page 63: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/63.jpg)
Price and Currency
Showing localized price
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];[numberFormatter setLocale:product.priceLocale];NSString *formattedString = [numberFormatter stringFromNumber:product.price];
![Page 64: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/64.jpg)
Price and Currency
Showing localized price
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];[numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];[numberFormatter setLocale:product.priceLocale];NSString *formattedString = [numberFormatter stringFromNumber:product.price];
Do not perform currency conversion!
![Page 65: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/65.jpg)
Handling Errors
![Page 66: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/66.jpg)
Handling Errors
Not all errors are equal
![Page 67: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/67.jpg)
Handling Errors
Not all errors are equal
Check the error code
![Page 68: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/68.jpg)
Handling Errors
Not all errors are equal
Check the error code• Don’t show an error alert unless necessary
![Page 69: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/69.jpg)
Handling Errors
Not all errors are equal
Check the error code• Don’t show an error alert unless necessary
• User canceling a payment will result in an error
![Page 70: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/70.jpg)
Handling Errors
Not all errors are equal
Check the error code• Don’t show an error alert unless necessary
• User canceling a payment will result in an error
Let StoreKit handle the transaction flow as much as possible
![Page 71: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/71.jpg)
Making the Purchase
![Page 72: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/72.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
ShowIn-App UI
![Page 73: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/73.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
MakePurchase
![Page 74: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/74.jpg)
The Payment QueueObserve it, always
![Page 75: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/75.jpg)
The Payment QueueObserve it, always
The center of your In-App Purchase implementation • The only source of truth for state
![Page 76: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/76.jpg)
The Payment QueueObserve it, always
The center of your In-App Purchase implementation • The only source of truth for state
Rely on the queue, and only the queue • For transactions in progress
• Payment status updates
• Download status
![Page 77: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/77.jpg)
The Payment QueueObserve it, always
The center of your In-App Purchase implementation • The only source of truth for state
Rely on the queue, and only the queue • For transactions in progress
• Payment status updates
• Download status
Any and all transactions in the queue are valid and real
![Page 78: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/78.jpg)
On Launch
Start observing the payment queue
![Page 79: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/79.jpg)
On Launch
Start observing the payment queue
[[SKPaymentQueue defaultQueue] addTransactionObserver:yourObserver];
![Page 80: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/80.jpg)
ExampleFetch product info
Get information about your products from the store
![Page 81: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/81.jpg)
ExampleFetch product info
Get information about your products from the store
NSSet* identifierSet = [NSSet setWithArray:productIdentifiers];
![Page 82: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/82.jpg)
ExampleFetch product info
Get information about your products from the store
NSSet* identifierSet = [NSSet setWithArray:productIdentifiers];
SKProductsRequest* request = [[SKProductsRequest alloc]
initWithProductIdentifiers: identifierSet];
![Page 83: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/83.jpg)
ExampleFetch product info
Get information about your products from the store
NSSet* identifierSet = [NSSet setWithArray:productIdentifiers];
SKProductsRequest* request = [[SKProductsRequest alloc]
initWithProductIdentifiers: identifierSet];
request.delegate = self;
![Page 84: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/84.jpg)
ExampleFetch product info
Get information about your products from the store
NSSet* identifierSet = [NSSet setWithArray:productIdentifiers];
SKProductsRequest* request = [[SKProductsRequest alloc]
initWithProductIdentifiers: identifierSet];
request.delegate = self;
[request start];
![Page 85: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/85.jpg)
ExampleAdd payment to queue
Start the payment transaction
![Page 86: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/86.jpg)
ExampleAdd payment to queue
Start the payment transaction
SKPayment* payment = [SKPayment paymentWithProduct:product];
![Page 87: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/87.jpg)
ExampleAdd payment to queue
Start the payment transaction
SKPayment* payment = [SKPayment paymentWithProduct:product];[[SKPaymentQueue defaultQueue] addPayment:payment];
![Page 88: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/88.jpg)
ExampleHandle events
![Page 89: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/89.jpg)
ExampleHandle events
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
![Page 90: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/90.jpg)
ExampleHandle events
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
for (SKPaymentTransaction* transaction in transactions)
![Page 91: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/91.jpg)
ExampleHandle events
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
for (SKPaymentTransaction* transaction in transactions){
switch(transaction.transactionState) {
![Page 92: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/92.jpg)
ExampleHandle events
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
for (SKPaymentTransaction* transaction in transactions){
switch(transaction.transactionState) { case SKPaymentTransactionStatePurchased:
![Page 93: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/93.jpg)
ExampleHandle events
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions{
for (SKPaymentTransaction* transaction in transactions){
switch(transaction.transactionState) { case SKPaymentTransactionStatePurchased:
NSURL* receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData* receipt = [NSData dataWithContentsOfURL:receiptURL];
// Process the transaction }}
![Page 94: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/94.jpg)
Don’t Do This
case SKPaymentTransactionStatePurchased:
// Get the local state for this transaction
![Page 95: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/95.jpg)
Don’t Do This
case SKPaymentTransactionStatePurchased:
// Get the local state for this transaction
SKPayment *payment = myCachedPayments[transaction.payment.productIdentifier];
![Page 96: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/96.jpg)
Don’t Do This
case SKPaymentTransactionStatePurchased:
// Get the local state for this transaction
SKPayment *payment = myCachedPayments[transaction.payment.productIdentifier];
if (!payment)
{
![Page 97: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/97.jpg)
Don’t Do This
case SKPaymentTransactionStatePurchased:
// Get the local state for this transaction
SKPayment *payment = myCachedPayments[transaction.payment.productIdentifier];
if (!payment)
{
// No idea where this transaction came from!
// Ignore it
continue;
}
![Page 98: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/98.jpg)
Don’t Do This
case SKPaymentTransactionStatePurchased:
// Get the local state for this transaction
SKPayment *payment = myCachedPayments[transaction.payment.productIdentifier];
if (!payment)
{
// No idea where this transaction came from!
// Ignore it
continue;
}
Tracking your own state or payment cache is unnecessary
![Page 99: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/99.jpg)
Why Not?
![Page 100: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/100.jpg)
Why Not?
Because, what if… • You crash
• Purchase is disrupted
• Or your app didn’t even start the purchase
![Page 101: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/101.jpg)
Why Not?
Because, what if… • You crash
• Purchase is disrupted
• Or your app didn’t even start the purchase
The transaction is just as valid
• Process it always
![Page 102: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/102.jpg)
ExampleHandling deferred transaction
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{ for (SKPaymentTransaction* transaction in transactions) {
switch(transaction.transactionState) { !
!
!
!
} } }
![Page 103: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/103.jpg)
ExampleHandling deferred transaction
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{ for (SKPaymentTransaction* transaction in transactions) {
switch(transaction.transactionState) { !
!
!
!
} } }
case SKPaymentTransactionStateDeferred:
![Page 104: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/104.jpg)
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{ for (SKPaymentTransaction* transaction in transactions) {
switch(transaction.transactionState) { !
!
!
!
} } }
ExampleHandling deferred transaction
case SKPaymentTransactionStateDeferred:
![Page 105: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/105.jpg)
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{ for (SKPaymentTransaction* transaction in transactions) {
switch(transaction.transactionState) { !
!
!
!
} } }
ExampleHandling deferred transaction
case SKPaymentTransactionStateDeferred:
// Allow the user to continue to use the app
![Page 106: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/106.jpg)
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{ for (SKPaymentTransaction* transaction in transactions) {
switch(transaction.transactionState) { !
!
!
!
} } }
ExampleHandling deferred transaction
case SKPaymentTransactionStateDeferred:
// Allow the user to continue to use the app
// It may be some time before the transaction is updated
![Page 107: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/107.jpg)
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{ for (SKPaymentTransaction* transaction in transactions) {
switch(transaction.transactionState) { !
!
!
!
} } }
ExampleHandling deferred transaction
case SKPaymentTransactionStateDeferred:
// Allow the user to continue to use the app
// It may be some time before the transaction is updated
// Do not get stuck in a modal “Purchasing…” state!
![Page 108: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/108.jpg)
ExampleFinish the transaction
![Page 109: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/109.jpg)
ExampleFinish the transaction
Always finish the transaction
![Page 110: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/110.jpg)
ExampleFinish the transaction
Always finish the transaction
- (void)finishTransaction:(SKPaymentTransaction *)transaction
![Page 111: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/111.jpg)
ExampleFinish the transaction
Always finish the transaction
- (void)finishTransaction:(SKPaymentTransaction *)transaction
Tells the store that your app has finished processing the transaction • The transaction will be removed from the queue
![Page 112: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/112.jpg)
SKPaymentQueue Tips
![Page 113: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/113.jpg)
SKPaymentQueue Tips
@property(nonatomic, readonly) NSArray *transactions;
• No need for you to keep track of transactions in-flight, trust the queue
![Page 114: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/114.jpg)
SKPaymentQueue Tips
@property(nonatomic, readonly) NSArray *transactions;
• No need for you to keep track of transactions in-flight, trust the queue
+ (BOOL)canMakePayments
• Known if In-App Purchases have been restricted
![Page 115: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/115.jpg)
DemoTrouble free In-App Purchase
![Page 116: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/116.jpg)
Post-Sale Experience
![Page 117: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/117.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
MakePurchase
![Page 118: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/118.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
ProcessTransaction
![Page 119: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/119.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
Make Asset Available
![Page 120: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/120.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
FinishTransaction
![Page 121: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/121.jpg)
Post-Sale Experience
![Page 122: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/122.jpg)
Post-Sale Experience
Validate the purchase • Receipt verification on-device or server-to-server
![Page 123: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/123.jpg)
Post-Sale Experience
Validate the purchase • Receipt verification on-device or server-to-server
Download content • Hosted In-App Purchase content
• Self-hosted
![Page 124: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/124.jpg)
Post-Sale Experience
Validate the purchase • Receipt verification on-device or server-to-server
Download content • Hosted In-App Purchase content
• Self-hosted
Persisting and restoring transactions
![Page 125: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/125.jpg)
Receipt Validation
![Page 126: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/126.jpg)
Receipt Validation
On-device validation • Unlock features and content within the app
![Page 127: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/127.jpg)
Receipt Validation
On-device validation • Unlock features and content within the app
Server-to-server validation • Restrict access to downloadable content
![Page 128: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/128.jpg)
Receipt Validation
Do not use online validation directly from the device!
iOS 6 APIs for receipt validation are deprecated
![Page 129: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/129.jpg)
Downloading Content
Hosted In-App Purchase content
![Page 130: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/130.jpg)
Downloading Content
Hosted In-App Purchase content• Hosted on Apple’s servers
![Page 131: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/131.jpg)
Downloading Content
Hosted In-App Purchase content• Hosted on Apple’s servers
• Scalable and reliable
![Page 132: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/132.jpg)
Downloading Content
Hosted In-App Purchase content• Hosted on Apple’s servers
• Scalable and reliable
• Downloads in background
![Page 133: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/133.jpg)
Downloading Content
Hosted In-App Purchase content• Hosted on Apple’s servers
• Scalable and reliable
• Downloads in background
• Up to 2GB per in-app purchasable product
![Page 134: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/134.jpg)
Hosted Content
Start download
![Page 135: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/135.jpg)
Hosted Content
Start download
for(SKPaymentTransaction* transaction in transactions) { !
!
!
!
}
- (void)paymentQueue:(SKPaymentQueue *)queue
updatedTransactions:(NSArray *)transactions
![Page 136: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/136.jpg)
Hosted Content
Start download
for(SKPaymentTransaction* transaction in transactions) { !
!
!
!
}
- (void)paymentQueue:(SKPaymentQueue *)queue
updatedTransactions:(NSArray *)transactions
if(transaction.downloads)
![Page 137: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/137.jpg)
Hosted Content
Start download
for(SKPaymentTransaction* transaction in transactions) { !
!
!
!
}
- (void)paymentQueue:(SKPaymentQueue *)queue
updatedTransactions:(NSArray *)transactions
!
[[SKPaymentQueue defaultQueue] startDownloads:
transaction.downloads];
if(transaction.downloads)
![Page 138: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/138.jpg)
Hosted Content
Download progress
![Page 139: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/139.jpg)
Hosted Content
Download progress
- (void)paymentQueue:(SKPaymentQueue *)queue
updatedDownloads:(NSArray *)downloads;
![Page 140: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/140.jpg)
Hosted Content
Download progress
- (void)paymentQueue:(SKPaymentQueue *)queue
updatedDownloads:(NSArray *)downloads;
download.progress
download.timeRemaining
![Page 141: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/141.jpg)
Hosted Content
Download progress
- (void)paymentQueue:(SKPaymentQueue *)queue
updatedDownloads:(NSArray *)downloads;
download.progress
download.timeRemaining
download.state
download.error
![Page 142: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/142.jpg)
Hosted Content
Download progress
- (void)paymentQueue:(SKPaymentQueue *)queue
updatedDownloads:(NSArray *)downloads;
download.progress
download.timeRemaining
download.state
download.error
download.contentURL
When download.state is SKDownloadStateFinished
![Page 143: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/143.jpg)
Self-Hosted Content
Self-hosted downloadable content• Use background download APIs
![Page 144: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/144.jpg)
Self-Hosted Content
Self-hosted downloadable content• Use background download APIs
- Content is downloaded even when your app is not active
![Page 145: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/145.jpg)
Self-Hosted Content
Self-hosted downloadable content• Use background download APIs
- Content is downloaded even when your app is not active
- Using class NSURLConnection APIs has limitations
![Page 146: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/146.jpg)
Using NSURLSession for downloading content
Self-Hosted Content
![Page 147: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/147.jpg)
Using NSURLSession for downloading content
NSURLSessionConfiguration *config = [NSURLSessionConfiguration
backgroundSessionConfiguration:@"MyBackgroundSession"];
Self-Hosted Content
![Page 148: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/148.jpg)
Using NSURLSession for downloading content
NSURLSessionConfiguration *config = [NSURLSessionConfiguration
backgroundSessionConfiguration:@"MyBackgroundSession"];
NSURLSession *session = [NSURLSession sessionWithConfiguration:config
delegate:self delegateQueue:queue];
Self-Hosted Content
![Page 149: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/149.jpg)
Using NSURLSession for downloading content
NSURLSessionConfiguration *config = [NSURLSessionConfiguration
backgroundSessionConfiguration:@"MyBackgroundSession"];
NSURLSession *session = [NSURLSession sessionWithConfiguration:config
delegate:self delegateQueue:queue];
NSURLRequest *request = [NSURLRequest requestWithURL:myURL];
Self-Hosted Content
![Page 150: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/150.jpg)
Using NSURLSession for downloading content
NSURLSessionConfiguration *config = [NSURLSessionConfiguration
backgroundSessionConfiguration:@"MyBackgroundSession"];
NSURLSession *session = [NSURLSession sessionWithConfiguration:config
delegate:self delegateQueue:queue];
NSURLRequest *request = [NSURLRequest requestWithURL:myURL];
NSURLSessionDownloadTask *downloadTask = [session
downloadTaskWithRequest:request];
Self-Hosted Content
![Page 151: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/151.jpg)
NSURLSessionDownloadDelegate
Download progress
!
- (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didWriteData:(int64_t)bytesWritten totalBytesWritten:(int64_t)totalBytesWritten totalBytesExpectedToWrite:(int64_t)totalBytesExpectedToWrite
{ // do something with progress }
Self-Hosted Content
![Page 152: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/152.jpg)
NSURLSession
Reconnect to session on launch
!
- (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)())completionHandler {
NSURLSessionConfiguration *config = [NSURLSessionConfiguration backgroundSessionConfiguration:identifier];
NSURLSession *session = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:queue];
self.completionHandler = completionHandler; // call when done }
Self-Hosted Content
![Page 153: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/153.jpg)
Downloading Content
When the content is downloaded, finish the transaction
!
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
!
Otherwise, the payment will stay in the queue
![Page 154: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/154.jpg)
Restore Transactions
![Page 155: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/155.jpg)
Restore Completed Transactions
Restoring transactions allows the user to restore• Non-consumable in-app purchases
• Auto-renewing subscriptions
![Page 156: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/156.jpg)
Restore Completed Transactions
Restoring transactions allows the user to restore• Non-consumable in-app purchases
• Auto-renewing subscriptions
Consumables and non-renewable restrictions
![Page 157: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/157.jpg)
Restore Completed Transactions
Restoring transactions allows the user to restore• Non-consumable in-app purchases
• Auto-renewing subscriptions
Consumables and non-renewable restrictions• You must persist the state!
![Page 158: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/158.jpg)
Restore Completed Transactions
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
![Page 159: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/159.jpg)
Restore Completed Transactions
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
Observe the queue
![Page 160: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/160.jpg)
Restore Completed Transactions
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
Observe the queue - paymentQueue:restoreCompletedTransactionsFailedWithError:
![Page 161: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/161.jpg)
Restore Completed Transactions
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
Observe the queue - paymentQueue:restoreCompletedTransactionsFailedWithError: - paymentQueueRestoreCompletedTransactionsFinished
![Page 162: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/162.jpg)
Restore Completed Transactions
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
Observe the queue - paymentQueue:restoreCompletedTransactionsFailedWithError: - paymentQueueRestoreCompletedTransactionsFinished
Inspect the receipt and unlock content and features accordingly
![Page 163: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/163.jpg)
Restore Completed Transactions
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
![Page 164: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/164.jpg)
Restore Completed Transactions
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
Requires a network connection
![Page 165: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/165.jpg)
Restore Completed Transactions
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
Requires a network connection
May cause sign in prompt
![Page 166: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/166.jpg)
Restore Completed Transactions
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
Requires a network connection
May cause sign in prompt
Your app must offer to restore transactions
![Page 167: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/167.jpg)
Restore Completed Transactions
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions]
Requires a network connection
May cause sign in prompt
Your app must offer to restore transactions• But do not call try to restore unless requested by the user
![Page 168: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/168.jpg)
SummaryRecipe for trouble-free In-App Purchases
![Page 169: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/169.jpg)
In-App Purchase Process
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
![Page 170: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/170.jpg)
In-App Purchase Process
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
Load In-AppIdentifiers
![Page 171: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/171.jpg)
In-App Purchase Process
!
!
!
!
Server fetch of product identifiers
• Cache appropriately
• Avoid delay in presenting products
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
Load In-AppIdentifiers
![Page 172: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/172.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
Load In-AppIdentifiers
In-App Purchase Process
![Page 173: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/173.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
FetchProduct Info
In-App Purchase Process
![Page 174: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/174.jpg)
!
!
!
!
Fetch only the products you need
Fetch just ahead of time
• Avoid delay in presenting products
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
FetchProduct Info
In-App Purchase Process
![Page 175: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/175.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
FetchProduct Info
In-App Purchase Process
![Page 176: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/176.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
ShowIn-App UI
In-App Purchase Process
![Page 177: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/177.jpg)
!
!
!
!
Take care to ensure proper localization
Do not convert currencies
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
ShowIn-App UI
In-App Purchase Process
![Page 178: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/178.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
ShowIn-App UI
In-App Purchase Process
![Page 179: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/179.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
MakePurchase
In-App Purchase Process
![Page 180: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/180.jpg)
!
!
!
!
Add the payment to the queue
Then obey the queue, always
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
MakePurchase
In-App Purchase Process
![Page 181: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/181.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
MakePurchase
In-App Purchase Process
![Page 182: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/182.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
ProcessTransaction
In-App Purchase Process
![Page 183: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/183.jpg)
!
!
!
!
Verify the receipt
Unlock features and content
Avoid deprecated APIs and unsafe verification
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
ProcessTransaction
In-App Purchase Process
![Page 184: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/184.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
ProcessTransaction
In-App Purchase Process
![Page 185: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/185.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
Make Asset Available
In-App Purchase Process
![Page 186: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/186.jpg)
!
!
!
!
Content download
• Host content with Apple
• Use background download APIs
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
Make Asset Available
In-App Purchase Process
![Page 187: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/187.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
Make Asset Available
In-App Purchase Process
![Page 188: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/188.jpg)
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
FinishTransaction
In-App Purchase Process
![Page 189: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/189.jpg)
!
!
!
!
Always finish the transaction!
Keep your queue clean
ProcessTransaction
ShowIn-App UI
Make Asset Available
FetchProduct Info
MakePurchase
Load In-AppIdentifiers
FinishTransaction
FinishTransaction
In-App Purchase Process
![Page 190: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/190.jpg)
More Information
Documentation In-App Purchases Programming Guide https://developer.apple.com
Apple Developer Forums http://devforums.apple.com
![Page 191: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/191.jpg)
Related Sessions
• Preventing Unauthorized Purchases with Receipts Pacific Heights Friday 10:15AM
• Designing a Great In-App Purchase Experience Nob Hill Wednesday 11:30AM
• Kids and Apps Nob Hill Thursday 3:15PM
![Page 192: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/192.jpg)
Labs
• StoreKit and Receipts Lab Services Lab A Wednesday 3:15PM
• StoreKit and Receipts Lab Services Lab A Friday 10:15AM
• Open Hours Services Lab A Friday 2:00PM
![Page 193: Optimizing In-App Purchases€¦ · Store Product Sheet. StoreKit Features In-App Purchases ... Must allow the user to continue to use the app • Repurchasing the item is allowed](https://reader033.fdocuments.in/reader033/viewer/2022051809/60133caeb8139514fd089459/html5/thumbnails/193.jpg)