CalStorePageItemPurchasable Class Reference

Inherits from CalStorePageItem : CalStoreObject : NSObject
Declared in CalStorePageItemPurchasable.h

Overview

Abstract Base Class for items that can be purchased by the user. Check the canBePurchased flag to check if the item is actually purchasable, since some items might not have in-app identifiers associated with them.

Objects of this class can be purchased by the user. After an object has been purchased, the user can either install all calendars of the CalStorePageItemPage or install the CalStorePageItemCalendar.

In-App Purchases Since SDK v2.0 this class is used for the auto-renewable subscriptions. CalStoreSubscription will remain the only instance of CalStorePageItemPurchasable. To check the status of the subscription query the shared subscription with [CalStoreSubscriptionHandler sharedSubscription]

Purchasing and Installing

To give the user access to this items content, use the following steps:

  1. Observe the kCalStoreOrderStatusChangedNotification notification for state changes about this item’s state. Update your UI accordingly.
  2. Check if the purchased property of the CalStoreSubscription is YES and beingPurchased does not indicate a purchase is currently in progress.
  3. If not, start an async purchase operation using purchaseWithCompletionHandler: for the CalStoreSubscription and in the completion handler show errors to the user when needed.
  4. During purchasing, the beingPurchased property will return YES to indicate a purchase is in progress.
  5. If the completionHandler indicated success, check the purchased property again.
  6. If it returns YES, then the calendar can be installed using the CalStoreInstallCalendarViewController in case of CalStorePageItemCalendar. In case of a CalStorePageItemPage, the user can install any of the items of that page.

Use the canBePurchased property to see if an item can actually be purchased using the in-app purchasing system.

In-App Purchase Info

  productIdentifier

The identifier of the in-app purchase that this item is a part of.

@property (nonatomic, readonly) NSString *productIdentifier

Declared In

CalStorePageItemPurchasable.h

  relatedProductIdentifiers

The set of in-app purchase identifiers for the same in-app purchase for other, related apps of the same vendor. Nil if not applicable.

@property (nonatomic, readonly) NSSet *relatedProductIdentifiers

Discussion

Some apps choose to have a different iPad an iPhone version of the same app. Since those are technically two different apps, they have different in-app purchase identifiers. However, for the user they appear as one app. This property will return the in-app purchase identifiers used by both apps for the same item.

See Also

Declared In

CalStorePageItemPurchasable.h

Store Integration

  canBePurchased

YES when this object can actually be purchased. Items can be purchased if they have a valid productIdentifier.

@property (nonatomic, readonly, getter=canBePurchased) BOOL canBePurchased

Discussion

Items can be purchased when they have a valid In-App purchase productIdentifier. CalStorePageItemCalendar items are generally always purchasable, while CalStorePageItemPage items are only purchasable if the items of the page it links to, are all part of the same in-app purchase.

Declared In

CalStorePageItemPurchasable.h

  purchased

YES when the in-app purchase that this item is a part of, has been purchased by the user.

@property (nonatomic, readonly, getter=isPurchased) BOOL purchased

Discussion

When this property is YES, this item can be installed using the CalStoreInstallCalendarViewController.

Declared In

CalStorePageItemPurchasable.h

  beingPurchased

YES when a purchasing operation is currently being undertaken

@property (nonatomic, readonly, getter=isBeingPurchased) BOOL beingPurchased

Declared In

CalStorePageItemPurchasable.h

– purchaseWithCompletionHandler:

Use this method to start a purchase operation for the in-app purchase that this item is a part of. During purchasing, the beingPurchased property will be yes.

- (void)purchaseWithCompletionHandler:(CalStoreOrderCompletionHandler)completionHandler

Parameters

completionHandler

the block to invoke when the purchase operation finished. When the success parameter of the block is YES, the purchase succeeded. However, always check the purchased property of the item before trying to install the item. For CalStorePageItemPage items, present a CalStoreCalendarStoreViewController after the purchase was successful, to allow the user to install any of the items.

Discussion

Observe kCalStoreOrderStatusChangedNotification notifications and check the [userInfo[kCalStoreOrderStatusChangedIdentifierKey] isEqual:item.identifier] to see if any changes in this items state occured. If so, update your UI accordingly.

Note: A purchase operation cannot be canceled by the app once it has been started.

Declared In

CalStorePageItemPurchasable.h

Getting Bundle Information

– calendarBundleRequest

Gets the CalStoreCalendarBundleRequest that can be used to fetch the CalStoreCalendarBundle that holds information about this purchasable item.

- (CalStoreCalendarBundleRequest *)calendarBundleRequest

Return Value

The request that can be used to fetch the CalStoreCalendarBundle with information about this purchasable. Can be nil if canBePurchased is NO.

Declared In

CalStorePageItemPurchasable.h

Price Information

  priceInfo

Information about the price of the in-app purchase that this item is a part of. When nil, use the fetchPriceInfoWithCompletionHandler: method to fetch the information asynchronously.

@property (nonatomic, readonly) CalStorePriceInfo *priceInfo

Declared In

CalStorePageItemPurchasable.h

Fetching Price Information

  fetchingPriceInfo

YES when this object is busy fetching PriceInfo.

@property (nonatomic, readonly, getter=isFetchingPriceInfo) BOOL fetchingPriceInfo

Declared In

CalStorePageItemPurchasable.h

– fetchPriceInfoWithCompletionHandler:

Fetches PriceInfo for this object. This method should be called when the priceInfo property is nil. When the fetch operation completes successfully, the priceInfo property will be set with the fetched PriceInfo.

- (void)fetchPriceInfoWithCompletionHandler:(CalStorePriceInfoCompletionHandler)completionHandler

Parameters

completionHandler

block that will be invoked when the fetch operation finished (sucessfully or not). The block will be invoked on the main queue.

Discussion

An ongoing fetch operation can be canceled using cancelFetchingPriceInfo.

Note: When fetchingPriceInfo is YES, an exception will be raised when calling this method.

Declared In

CalStorePageItemPurchasable.h

– cancelFetchingPriceInfo

Cancels an ongoing fetch operation for PriceInfo.

- (void)cancelFetchingPriceInfo

Declared In

CalStorePageItemPurchasable.h