bfgPurchase Class
Manages Apple's In-App Purchases for Free-to-Play games. More...
#import <bfgPurchase.h>
Class Methods | |
("Deprecated since iOS SDK 7.0. Refer to acquireProductInformation:productId instead.") | + __deprecated_msg |
(BOOL) | + acquireProductInformation: |
(BOOL) | + acquireProductInformationForProducts: |
(BOOL) | + canStartPurchase: |
(void) | + processDeferredPayments |
(BOOL) | + hasDeferredPayments |
("Deprecated since iOS SDK 7.0. Refer to startPurchase:productId instead.") | + __deprecated_msg |
(void) | + startPurchase: |
(void) | + startPurchase:details1:details2:details3:additionalDetails: |
("Deprecated since iOS SDK 7.0. Refer to finishPurchase:productId instead.") | + __deprecated_msg |
(void) | + finishPurchase: |
("Deprecated since iOS SDK 7.0. Refer to isPurchaseActive:productId instead.") | + __deprecated_msg |
(BOOL) | + isPurchaseActive: |
(BOOL) | + isRestoreActive |
("Deprecated since iOS SDK 7.0. Refer to productInformation:productId instead.") | + __deprecated_msg |
(NSDictionary *) | + productInformation: |
(void) | + restorePurchases |
(BOOL) | + startService |
(BOOL) | + startService: |
(NSArray< bfgPurchaseObject * > *) | + deliverablePurchases |
Completed purchases that have not been granted to the user. More... | |
(BOOL) | + purchaseActivityInProgress |
Detailed Description
Manages Apple's In-App Purchases for Free-to-Play games. If you are using these APIs, you should become an observer for the following events:
- NOTIFICATION_PURCHASE_PRODUCTINFORMATION
- NOTIFICATION_PURCHASE_SUCCEEDED
- NOTIFICATION_PURCHASE_FAILED
- NOTIFICATION_PURCHASE_DEFERRED
- NOTIFICATION_RESTORE_SUCCEEDED
- NOTIFICATION_RESTORE_FAILED
- Since
- 4.0.0
Method Documentation
◆ __deprecated_msg [1/5]
+ ("Deprecated since iOS SDK 7.0. Refer to) productInformation: |
- Returns
- Product information related to the default product.
- See also
- + productInformation:
- Deprecated:\n Deprecated since iOS SDK 7.0. Refer to productInformation:productId instead.
- Since
- 4.0.0
◆ __deprecated_msg [2/5]
+ ("Deprecated since iOS SDK 7.0. Refer to) startPurchase: |
Convenience method for calling startPurchase:details1:details2:details3:additionalDetails with nil details and nil additional details.
- See also
- + startPurchase: details1:details2:details3:additionalDetails:
- Deprecated:\n Deprecated since iOS SDK 7.0. Refer to startPurchase:productId instead.
- Since
- 4.2.0
◆ __deprecated_msg [3/5]
+ ("Deprecated since iOS SDK 7.0. Refer to) isPurchaseActive: |
- Returns
- Return values
YES The default product is currently being processed for purchase. NO Purchase already in-flight, restore in-flight, or other restriction preventing purchase.
- Deprecated:\n Deprecated since iOS SDK 7.0. Refer to isPurchaseActive:productId instead.
- Since
- 4.0.0
◆ __deprecated_msg [4/5]
+ ("Deprecated since iOS SDK 7.0. Refer to) acquireProductInformation: |
Requests product information of the default product from the App Store. This method must be called before the default product can be purchased.
- Returns
- Return values
YES The request for product information is sent to the App Store. NO The user is offline or the default productId is already being requested.
- Deprecated:\n Deprecated since iOS SDK 7.0. Refer to acquireProductInformation:productId instead.
- Since
- 4.0.0
◆ __deprecated_msg [5/5]
+ ("Deprecated since iOS SDK 7.0. Refer to) finishPurchase: |
Convenience method for calling finishPurchase: with the default productId.
- See also
- + finishPurchase:
- Deprecated:\n Deprecated since iOS SDK 7.0. Refer to finishPurchase:productId instead.
- Since
- 4.2.0
◆ acquireProductInformation:
+ (BOOL) acquireProductInformation: | (NSString *) | productId |
Requests product information from the App Store. This method must be called before the requested product can be purchased.If multiple products are being requested, it is much more efficient to use acquireProductInformationForProducts: rather than repeated calls to this method.
- Parameters
productId Identifier of a product that can be purchased in game.
- Returns
- Return values
YES The request for product information is sent to the App Store. NO The product information is already being requested.
- Since
- 4.0.0
◆ acquireProductInformationForProducts:
+ (BOOL) acquireProductInformationForProducts: | (NSSet *) | productIds |
Requests product information from the App Store. This method must be called before the requested products can be purchased.
- Parameters
productIds Set of identifiers of products that can be purchased in the game.
- Returns
- Return values
YES The request for product information has been sent to the App Store. NO All productIds are already being requested.
- Since
- 4.2.0
◆ canStartPurchase:
+ (BOOL) canStartPurchase: | (NSString *) | productId |
Checks whether it is possible to purchase a product at this time.For most applications, this is the API to call. You should specify a productId that was defined in iTunes Connect by your producer.This method presents the UI to users as they begin the purchase process.In order to provide a quick result, this method does not try to connect to Big Fish Games' purchase services server. This check will occur in startPurchase before a purchase is sent to Apple.
- Returns
- Return values
YES Purchase will succeed if started. NO Purchase already in-flight, restore in-flight, or other restriction preventing purchase.
- Since
- 4.2.0
◆ deliverablePurchases
+ (NSArray< bfgPurchaseObject * > *) deliverablePurchases |
Completed purchases that have not been granted to the user. When a purchase completes, you will receive a notification of its success or failure. At this time, award the purchase to the user. This method gives you a secondary way of accessing purchases that should be awarded after the notification has fired.
- Note
- You must start the bfgPurchase service before calling this method.
- Returns
- Purchase objects that were successfully purchased but have not had "finishPurchase" called on them.
- Since
- 5.9
◆ finishPurchase:
+ (void) finishPurchase: | (NSString *) | productId |
A call to this method is necessary for all successful purchases. Failed purchases and restores do not need to be finished.After performing the unlock and PERSISTING IT, this method must be called to take the purchase off the queue. If this method is not called, the app will be notified of the purchase every time bfgPurchase is restarted. The product cannot be purchased again until the previous purchase has been finished.Calling this method on a productId that is not currently being purchased does nothing.
- Parameters
productId The ID of the product to take off the queue.
- Since
- 4.2.0
◆ hasDeferredPayments
+ (BOOL) hasDeferredPayments |
Used to determine if the app has deferred payments from promoted in-app purchases.
- Since
- 7.6.0
◆ isPurchaseActive:
+ (BOOL) isPurchaseActive: | (NSString *) | productId |
- Parameters
productId ID of product to query if purchase is active.
- Returns
- Return values
YES Purchase is being processed. NO Purchase already in-flight, restore in-flight, or other restriction preventing purchase.
- Since
- 4.0.0
◆ isRestoreActive
+ (BOOL) isRestoreActive |
- Returns
- Return values
YES Restore is being processed or verified. NO Restore in-flight or other restriction preventing restore.
- Since
- 4.2.0
◆ processDeferredPayments
+ (void) processDeferredPayments |
Used to process deferred payments from promoted in-app purchases.
- Since
- 7.6.0
◆ productInformation:
+ (NSDictionary *) productInformation: | (NSString *) | productId |
Product information is obtained from Apple during acquireProductInformationForProducts: and held in a transient dictionary.Games should not persist this data but should acquire it on each launch from the iTunes Store.
- Returns
- A dictionary of information regarding the product with the following keys (pre-processor defines):
- Return values
PRODUCT_INFO_PRODUCT_ID Apple ID of the product. PRODUCT_INFO_PRICE Price as a number. PRODUCT_INFO_PRICE_STR Price as localized string. PRODUCT_INFO_TITLE Title of product. PRODUCT_INFO_DESCRIPTION Description of product. PRODUCT_INFO_CURRENCY Currency price is denoted in.
- Since
- 4.0.0
◆ purchaseActivityInProgress
+ (BOOL) purchaseActivityInProgress |
Checks if a purchase / restore is in progress. Should not be displayed.
- Returns
- Return values
YES Purchase or restore in progress. NO Purchase already in-flight, restore in-flight, or other restriction preventing purchase.
- Since
- 4.2.0
◆ restorePurchases
+ (void) restorePurchases |
Restores previous purchases. Receives the same NOTIFICATION_PURCHASE_SUCCEEDED notification as the original purchase.
- Since
- 4.2.0
◆ startPurchase:
+ (void) startPurchase: | (NSString *) | productId |
Convenience method for calling startPurchase:details1:details2:details3:additionalDetails with the default productId, nil details, and nil additional details.
- See also
- + startPurchase: details1:details2:details3:additionalDetails:
- Since
- 4.2.0
◆ startPurchase:details1:details2:details3:additionalDetails:
+ (void) startPurchase: | (NSString *) | productId | |
details1: | (NSString *) | details1 | |
details2: | (NSString *) | details2 | |
details3: | (NSString *) | details3 | |
additionalDetails: | (NSDictionary *) | additionalDetails | |
Attempt an In-App Purchase with the iTunes store.
- Parameters
productId Identifier of product to be purchased. Originates from the iTunes Store. details1 An alpha-numeric label to categorize the event. May be nil. details2 An alpha-numeric label to categorize the event. May be nil. details3 An alpha-numeric label to categorize the event. May be nil. additionalDetails Additional data to be associated with this productId. This value may be nil. If not nil, the value must be a flat dictionary containing only NSString * as keys and values.
- NOTIFICATION_PURCHASE_SUCCEEDED – Perform the unlock, persist the purchase, and call finishPurchase:
- NOTIFICATION_PURCHASE_FAILED – Inform the user the purchase failed.
- See also
- bfgPurchaseObject
- Since
- 4.2.0
◆ startService
+ (BOOL) startService |
Calling startService on bfgPurchases enables its functionality and causes it to resume processing any operations that were already in progress. All notification listeners should be set up prior to calling start.
- Returns
- Return values
YES Purchase has started. NO Purchase has previously started.
- Since
- 4.2.0
◆ startService:
+ (BOOL) startService: | (NSError *__autoreleasing *) | error |
Calling startService on bfgPurchases enables its functionality and causes it to resume processing any operations that were already in progress. All notification listeners should be set up prior to calling start.
- Parameters
error If service fails to start, error will contain the reason. Otherwise error is nil.
- Returns
- Return values
YES Purchase has started. NO Purchase has previously started.
- Since
- 4.7.0