CalStoreStoreKitController Class Reference

Inherits from NSObject
Declared in CalStoreStoreKitController.h
Companion guide MultipleApps

Overview

Controller that ties the CalendarStore into Apple’s StoreKit framework for In-App purchases.

Check if In-App Purchases are Enabled

Apps should also check if In-App purchases are enabled on the device by checking if [CalStoreStoreKitController sharedController].canUsePurchases returns YES.

Order Status Notification

When The StoreKitController changes the transaction status for a CalStorePageItemCalendar object being purchased, the kCalStoreOrderStatusChangedNotification notification is sent. userInfo[kCalStoreOrderStatusChangedIdentifierKey] contains the identifier of the item that changed status.

Refresh Notification

When the whole store gets refreshed, the kCalStoreOrderStatusRefreshAllNotification notification is sent. When receiving this notification, refresh all your UI so that changes can be reflected. This notification will be sent, for example, when in-app purchases are being synced in over iCloud.

Restoring Purchases

This controller allows the app to restore already made purchases using the restorePurchasesWithCompletionHandler: method. When the isRestoring property changes, the kCalStoreRestoringPurchasesStatusChangedNotification is broadcasted.

iCloud Integration

The CalendarStore.framework can sync purchasing information over iCloud to related apps of the same vendor. If you have multiple apps (e.g. an iPhone and iPad version) that are related, you can either set the CalendarStoreiCloudSyncEnabled key to YES in the Info.plist of your app, or use the iCloudSyncEnabled property to do so in code. For more information, see the MultipleApps companion guide.

Warning: Be aware that it is mandatory for users to be able to restore purchases. The default CalStoreCalendarStoreViewController will allow users to do this. If you provide your own CalendarStore UI, you must provide users an option to restore purchases.

Getting Instance

+ sharedController

Returns the singleton controller object

+ (instancetype)sharedController

Return Value

the singleton controller used by the framework

Declared In

CalStoreStoreKitController.h

Purchases Enabled

– canUsePurchases

Checks if Purchases can be made by the user.

- (BOOL)canUsePurchases

Return Value

YES if the user has in-app purchases enabled on his device.

Discussion

Users can disable In-App purchases in the Parental Control settings of their device. Always check this before showing the Calendar Store.

Declared In

CalStoreStoreKitController.h

Restoring Purchases

– restorePurchasesWithCompletionHandler:

Starts restoring purchases already made by the user.

- (void)restorePurchasesWithCompletionHandler:(CalStoreStoreKitCompletionHandler)completionHandler

Parameters

completionHandler

block invoked on the main queue when the restore operation finished.

Discussion

Note: When restoring is YES, calling this method will raise an exception.

Declared In

CalStoreStoreKitController.h

  restoring

YES when purchases are being restored.

@property (nonatomic, readonly, getter=isRestoring) BOOL restoring

Discussion

kCalStoreRestoringPurchasesStatusChangedNotification notifications are broadcasted when the value of this option changes. Observe the notification to update your UI accordingly.

Declared In

CalStoreStoreKitController.h

iCloud Integration

  iCloudSyncEnabled

When YES, iCloud sync of purchasing information is enabled. If NO, iCloud sync is disabled.

@property (nonatomic, assign, getter=isiCloudSyncEnabled) BOOL iCloudSyncEnabled

Discussion

The CalendarStore.framework can sync purchasing information over iCloud to related apps of the same vendor. If you have multiple apps (e.g. an iPhone and iPad version) that are related, you can either set the CalendarStoreiCloudSyncEnabled key to YES in the Info.plist of your app, or use the iCloudSyncEnabled property to do so in code. For more information, see the MultipleApps companion guide.

Note: You will need to enable iCloud entitlements in your XCode project for this to work.

Declared In

CalStoreStoreKitController.h