EMBPurchaseFlow
@interface EMBPurchaseFlow : EMBCustomFlow
This class is responsible for tracking app performance during purchase flows.
This class is thread-safe.
-
Starts an add-to-cart app moment.
This method should be called as soon as the user indicates an intent to add an item to their cart.
Declaration
Objective-C
- (nonnull NSString *)addToCartStartWithItemId:(nullable NSString *)itemId quantity:(nullable NSNumber *)quantity price:(nullable NSNumber *)price properties: (nullable EMBProperties *)properties;
Swift
func addToCartStart(withItemId itemId: String?, quantity: NSNumber?, price: NSNumber?, properties: [String : String]?) -> String
Parameters
itemId
The ID that represents the item being added to the cart. This value is optional and, if present, will associate the value as a property of the moment.
quantity
The number of items being added to the cart. This value is optional and, if present, will associate the value as a property of the moment.
price
The unit price of the item being added to the cart. This value is optional and, if present, will associate the value as a property of the moment.
properties
A map of Strings to Objects that represent additional properties to associate with the moment. This value is optional. A maximum of 10 properties (not including the ones set via arguments to this method) may be set.
Return Value
A moment identifier that can be used to close the add-to-cart moment. If an error was encountered, this method returns null.
-
Ends a particular add-to-cart moment instance and generates an info log message that indicates that adding to the cart completed.
This method should be called once the item is verified to be in the user’s cart.
Declaration
Objective-C
- (BOOL)addToCartCompleteWithMomentId:(nonnull NSString *)momentId;
Swift
func addToCartComplete(withMomentId momentId: String) -> Bool
Parameters
momentId
The moment identifier returned by the
PurchaseFlow.addToCartStart
method. This moment identifier must be an identifier produced by this particular PurchaseFlow instance and must not have already been marked as completed or failed.Return Value
True if the operation was successful; false otherwise.
-
Ends a particular add-to-cart moment instance and generates an info log message that indicates that adding to the cart completed.
This method should be called once the item is verified to be in the user’s cart.
Declaration
Objective-C
- (BOOL)addToCartCompleteWithMomentId:(nonnull NSString *)momentId properties:(nullable EMBProperties *)properties;
Swift
func addToCartComplete(withMomentId momentId: String, properties: [String : String]?) -> Bool
Parameters
momentId
The moment identifier returned by the
PurchaseFlow.addToCartStart
method. This moment identifier must be an identifier produced by this particular PurchaseFlow instance and must not have already been marked as completed or failed.properties
A map of Strings to Objects that represent additional properties to associate with the moment. This value is optional. A maximum of 10 properties (not including the ones set via arguments to this method) may be set.
Return Value
True if the operation was successful; false otherwise.
-
Ends a particular add-to-cart moment instance and generates an error log message that indicates that adding to the cart failed.
This method should be called when it has been determined that the item could not be added to the cart.
Declaration
Objective-C
- (BOOL)addToCartFailWithMomentId:(nonnull NSString *)momentId message:(nullable NSString *)message;
Swift
func addToCartFail(withMomentId momentId: String, message: String?) -> Bool
Parameters
momentId
The moment identifier returned by the
PurchaseFlow.addToCartStart
method. This moment identifier must be an identifier produced by this particular PurchaseFlow instance and must not have already been marked as completed or failed.message
A message that explains the reason for why this operation failed. This value is optional and, if provided, will associate the value as a property of the error log message.
Return Value
True if the operation was successful; false otherwise.
-
Ends a particular add-to-cart moment instance and generates an error log message that indicates that adding to the cart failed.
This method should be called when it has been determined that the item could not be added to the cart.
Declaration
Objective-C
- (BOOL)addToCartFailWithMomentId:(nonnull NSString *)momentId message:(nullable NSString *)message properties:(nullable EMBProperties *)properties;
Swift
func addToCartFail(withMomentId momentId: String, message: String?, properties: [String : String]?) -> Bool
Parameters
momentId
The moment identifier returned by the
PurchaseFlow.addToCartStart
method. This moment identifier must be an identifier produced by this particular PurchaseFlow instance and must not have already been marked as completed or failed.message
A message that explains the reason for why this operation failed. This value is optional and, if provided, will associate the value as a property of the error log message.
properties
A map of Strings to Objects that represent additional properties to associate with the moment. This value is optional. A maximum of 10 properties (not including the ones set via arguments to this method) may be set.
Return Value
True if the operation was successful; false otherwise.
-
Starts a purchase moment.
This method should be called as soon as the user indicates an intent to purchase the items in their cart. This means that all information pertaining to the order (e.g. billing, payment, shipping) should already be known prior to invoking this method.
Declaration
Objective-C
- (BOOL)purchaseStartWithOrderId:(nullable NSString *)orderId numItems:(nullable NSNumber *)numItems amount:(nullable NSNumber *)amount paymentType:(nullable NSString *)paymentType properties:(nullable EMBProperties *)properties;
Swift
func purchaseStart(withOrderId orderId: String?, numItems: NSNumber?, amount: NSNumber?, paymentType: String?, properties: [String : String]?) -> Bool
Parameters
orderId
The ID that represents the purchase order. This value is optional and, if present, will associate the value as a property of the moment.
numItems
The number of items in the purchase order. This value is optional and, if present, will associate the value as a property of the moment.
amount
The total amount of the purchase order. This value is optional and, if present, will associate the value as a property of the moment.
paymentType
The payment system that will be fulfilling the purchase order (e.g. Google IAB, PayPal, BrainTree). This value is optional and, if present, will associate the value as a property of the moment.
properties
A map of Strings to Objects that represent additional properties to associate with the moment. This value is optional. A maximum of 10 properties (not including the ones set via arguments to this method) may be set.
Return Value
True if the operation was successful; false otherwise.
-
Ends the purchase moment and generates an info log message that indicates that the purchase completed.
This method should be called once the purchase order has been confirmed.
Declaration
Objective-C
- (BOOL)purchaseComplete;
Swift
func purchaseComplete() -> Bool
Return Value
True if the operation was successful; false otherwise.
-
Ends the purchase moment and generates an info log message that indicates that the purchase completed.
This method should be called once the purchase order has been confirmed.
Declaration
Objective-C
- (BOOL)purchaseCompleteWithProperties:(nullable EMBProperties *)properties;
Swift
func purchaseComplete(withProperties properties: [String : String]?) -> Bool
Parameters
properties
A map of Strings to Objects that represent additional properties to associate with the moment. This value is optional. A maximum of 10 properties (not including the ones set via arguments to this method) may be set.
Return Value
True if the operation was successful; false otherwise.
-
Ends the purchase moment and generates an error log message that indicates that the purchase failed.
This method should be called once the purchase order has been confirmed.
Declaration
Objective-C
- (BOOL)purchaseFailWithMessage:(nullable NSString *)message;
Swift
func purchaseFail(withMessage message: String?) -> Bool
Parameters
message
A message that explains the reason for why this operation failed. This value is optional and, if provided, will associate the value as a property of the error log message.
Return Value
True if the operation was successful; false otherwise.
-
Ends the purchase moment and generates an error log message that indicates that the purchase failed.
This method should be called once the purchase order has been confirmed.
Declaration
Objective-C
- (BOOL)purchaseFailWithMessage:(nullable NSString *)message properties:(nullable EMBProperties *)properties;
Swift
func purchaseFail(withMessage message: String?, properties: [String : String]?) -> Bool
Parameters
message
A message that explains the reason for why this operation failed. This value is optional and, if provided, will associate the value as a property of the error log message.
properties
A map of Strings to Objects that represent additional properties to associate with the moment. This value is optional. A maximum of 10 properties (not including the ones set via arguments to this method) may be set.
Return Value
True if the operation was successful; false otherwise.