Inherits from NSObject
Conforms to SKPaymentTransactionObserver
Declared in SCStoreObserver.h

Overview

SCStoreObserver is an SKPaymentTransactionObserver handling StoreKit transactions.

Any purchase transaction will result in an action to add credit to the users account. For this, the developer has to specific the products first which are available for purchase. Please see the StoreKit Guide for more information on how to add product for Apple InApp purchase. All product must be consumable items. Recurring transactions are not supported yet. Please use the SCPurchaseController to initiate any purchase transactions.

Class Methods

instance

Returns an existing instance of SCStoreObserver or nil

+ (instancetype)instance

Return Value

The SCStoreObserver or nil

Declared In

SCStoreObserver.h

new

Create a new instance of SCStoreObserver

+ (instancetype)new

Return Value

An instance of SCStoreObserver

Discussion

It’s recommended to create an instance of SCStoreObserver in application:didFinishLaunching:withOptions: in your AppDelegate. This tells the subsystem, that your application is using the StoreKit for InApp purchases.

In application:didFinishLaunching:withOptions: do the following:

// Create a new Instance
SCStoreObserver *observer = [SCStoreObServer new];

// Add your products
[observer addConsumableProduct:@"ProductId-1" ceditValue:99 currency:SC_CURRENCY_USD]; // 99 Cent/$ Credit
[observer addConsumableProduct:@"ProductId-2" ceditValue:500 currency:SC_CURRENCY_USD]; // 5 $ Credit
[observer addConsumableProduct:@"ProductId-3" ceditValue:99 currency:SC_CURRENCY_EUR];  // 99 Cent/EUR Credit
[observer addConsumableProduct:@"ProductId-4" ceditValue:500 currency:SC_CURRENCY_EUR]; // 5 EUR Credit

Declared In

SCStoreObserver.h

setInstance:

+ (void)setInstance:(id)observer

Instance Methods

addConsumableProduct:creditValue:currency:

Add the products available for InApp purchase in that app.

- (void)addConsumableProduct:(id)identifier creditValue:(id)valueInCents currency:(id)currency

Parameters

identifier
  • The iTunes Connect Product Id
valueInCents
  • The cent value the user will get in his account, when purchaseing this product
currency
  • The currency for the credit (EUR / USD / GBP)

Discussion

In iTunes Connect you can create consumable products at a certain Tier price. For every product created in iTunes Connect, that product has to be added here with Product ID and corresponding value in cent credits for the user.

Declared In

SCStoreObserver.h

hasOpenTransactions

Check whether there are still open transactions

- (BOOL)hasOpenTransactions

Return Value

YES / NO

Declared In

SCStoreObserver.h

productForId:

Returns the Product NSDictionary for the specific product id.

- (NSDictionary *)productForId:(id)identifier

Return Value

The product as NSDictionary.

Discussion

The NSDictionary contains the follwoing keys:

- identifier : The Product Id
- value : The value in cent as NSNumber
- currency : The currency as NSString (EUR / USD / GBP)

Declared In

SCStoreObserver.h

productIds

Returns a set of product ids added as consumable product.

- (NSSet *)productIds

Return Value

The product ids.

Declared In

SCStoreObserver.h