StoreFront
@objc public class StoreFront: NSObject
Handles the flow of a real money or game currency purchase.
-
The delegate that handles the completed purchases. If there are existing transactions in the queue they will be sent to the delegate when it is set.
Declaration
Swift
public weak var delegate: StoreFrontDelegate? = nil -
The shared singleton instance.
Declaration
Swift
public static let instance = StoreFront() -
Is used to determine if a user can afford a product purchased with game currency.
Declaration
Swift
public weak var playerInventory: IPlayerInventory? = nil -
This should be called before initialization. This method will register the SDK version with DarkMatter.
Declaration
Swift
public func preInitialize() -
Initializes the System by passing a reference to the player’s inventory. Hooks into the Manifest updated event and extracts settings data from manifest.
Declaration
Swift
public func initializeFromManifest() -
Starts the purchase flow. The invalid product event will be triggered if the product could not be found in the list.
Declaration
Swift
public func purchaseProduct(productID: String)Parameters
productIDUnique id of the product to purchase.
-
This method is invoked by the InAppPurchase static class upon a successful real money purchase.
Declaration
Swift
public func purchaseSuccessful(productID: String, transactionID: String, wasRestored: Bool)Parameters
productIDThe product ID of the purchase.
transactionIDThe transaction ID of the purchase.
wasRestoredIf the purchase was a restore.
-
This method is invoked by the IAP class when a real money purchase fails for multiple reasons.
Declaration
Swift
public func transactionFailed(productID: String, failReason: FailReason, errorCode: Int, details: String)Parameters
productIDThe product ID of the purchase.
failReasonThe reason for the failed purchase
errorCodeAn error code for the failure
detailsA more detailed error message in english
-
This method is invoked by the underlying IAPListener class when registration server fails portion of the purchase flow.
Declaration
Swift
public func purchaseProcessingFailed(productID: String, failReason: FailReason, details: String)Parameters
productIDThe product ID of the purchase.
failReasonThe reason for the failed purchase
detailsError message
-
Initialates the restore transactions flow. The same events are dispatched upon success re purchase and failures.
Declaration
Swift
public func restorePurchases() -
This method is invoked by the IAP class when a real money restore purchase fails for multiple reasons.
Declaration
Swift
public func restorePurchasesFailed(productID: String, failReason: FailReason, errorCode: Int, details: String)Parameters
productIDThe product ID of the purchase.
failReasonThe reason for the failed purchase
errorCodeAn error code for the failure
detailsA more detailed error message in english
-
This method is invoked by the underlying IAPListener class when registration server fails portion of the restore purchase flow.
Declaration
Swift
public func restorePurchaseProcessingFailed(productID: String, failReason: FailReason, details: String)Parameters
productIDThe product ID of the purchase.
failReasonThe reason for the failed purchase
detailsError message
-
Method is invoked by the underlying IAPListener class when the restore purchases flow has completed. The onRestorePurchasesComplete event is dispatched to notify.
Declaration
Swift
public func restorePurchaseProcessingFinished(succeeded: Bool)Parameters
succeededWhether or not the restore process completed successfully.
-
Method returns a store model and store items of type TStoreItem for a giving store id and sub state. Please note, this methods creates new StoreState models, it does not cache them. The StoreState returned by this method will not have a chronos timer reference.
Declaration
Swift
public func createStoreState<TStoreFrontItem>(storeName: String, storeState: String = "default") -> StoreState<TStoreFrontItem>? where TStoreFrontItem : BaseStoreStateProductParameters
storeNameThe string id of the store parent to retrieve data for.
storeStateThe child store state for the parent storeId. If storeState is null,
default
will be used as the state name.Return Value
A StoreData model containing store items of type TStoreItem
-
Method returns a store model and store items of type TStoreItem for the current active state. Please note, this methods creates new StoreState models, it does not cache them.
Declaration
Swift
public func createActiveStoreState<TStoreFrontItem>(storeName: String) -> StoreState<TStoreFrontItem>? where TStoreFrontItem : BaseStoreStateProductParameters
storeNameThe string id of the store parent to find the active state of.
Return Value
A StoreData model containing store items of type TStoreItem
-
Returns a product for the given SKU. Returns nil if the product cannot be found.
Declaration
Swift
public func getProductForSku(sku: String) -> ProductData?Parameters
skuThe SKU of the product you are trying to find.
Return Value
A ProductData model for the SKU.
-
Returns a product id string for the given product. Returns nil if the product id cannot be found.
-parameter product: The product object.
Declaration
Swift
public func getIdForProduct(product: ProductData) -> String?Return Value
A product string id.
-
Returns a product’s data for the given string id. Returns nil if the product cannot be found.
Declaration
Swift
public func getProductForId(productId: String) -> ProductData?Parameters
productIdString id of the product
Return Value
A ProductData object
StoreFront Class Reference