BRAccountLinkingManager
Objective-C
@interface BRAccountLinkingManager : NSObject
Swift
class BRAccountLinkingManager : NSObject
Use this interface to manage users’ linked retailer accounts for parsing e-receipts. Here is the basic flow:
- Implement UI to capture the user’s credentials to one or more retailers from the supported list (see
BRAccountLinkingRetailer
enum) - Store these using
-[BRAccountLinkingManager linkAccountWithCredentials:]
- Call
-[BRAccountLinkingManager grabNewOrdersWithCompletion:]
- The callback to this method will return all order details available since the most recent successful invocation
-
Declaration
Objective-C
+ (nonnull instancetype)shared;
Swift
class func shared() -> Self
-
Returns current version
Declaration
Objective-C
@property (nonatomic, copy, readonly) NSString *_Nonnull version;
Swift
var version: String { get }
-
A completion handler to receive updates from a background operation when enabled via
enableBackgroundFetchWithIdentifier
BRAccountLinkingRetailer retailer
- the retailer for this orderBRScanResults *results
- the current orderBRAccountLinkingError error
- any error that was encountered while attempting to grab ordersNSString *sessionId
- a unique session GUID that can be reported for debugging purposesDeclaration
Objective-C
@property (nonatomic, copy, nullable) void (^) (BRAccountLinkingRetailer, BRAccountLinkingError, NSString *_Nullable, BRScanResults *_Nullable) backgroundFetchCompletion;
Swift
var backgroundFetchCompletion: ((BRAccountLinkingRetailer, BRAccountLinkingError, String?, BRScanResults?) -> Void)? { get set }
-
Link a retailer connection
Declaration
Objective-C
- (BRAccountLinkingError)linkRetailerWithConnection: (nonnull BRAccountLinkingConnection *)connection;
Swift
func linkRetailer(with connection: BRAccountLinkingConnection) -> BRAccountLinkingError
Parameters
connection
The retailer configuration
Return Value
Any
BRAccountLinkingError
error that was encountered while attempting to link this retailer -
Verify connection for a given retailer
Declaration
Objective-C
- (BRAccountLinkingConnectionIdentifier *_Nullable) verifyRetailerWithConnection: (nonnull BRAccountLinkingConnection *)connection withCompletion: (nonnull void (^)(BRAccountLinkingError, UIViewController *_Nullable, NSString *_Nonnull))completion;
Swift
func verifyRetailer(with connection: BRAccountLinkingConnection, withCompletion completion: @escaping (BRAccountLinkingError, UIViewController?, String) -> Void) -> BRAccountLinkingConnectionIdentifier?
Parameters
connection
The account connection you want to verify
completion
Callback will be executed after verification has been attempted
BRAccountLinkingError error
- any error that was encountered while attempting to verify the accountUIViewController *vc
- for 2FA and other scenarios requiring user interaction, this will contain a reference to a view controller that should be shown or dismissed depending on the particularerror
valueNSString *sessionId
- a unique session GUID that can be reported for debugging purposes
Return Value
A BRAccountLinkingConnectionIdentifier that can be used to cancel the task
-
Returns all retailers for which there is a linked account
Declaration
Objective-C
- (nonnull NSArray<NSNumber *> *)getLinkedRetailers;
Swift
func getLinkedRetailers() -> [NSNumber]
Return Value
An array of
NSNumber*
wrapped values from theBRAccountLinkingRetailer
enum -
Returns a linked account configuration
Declaration
Objective-C
- (BRAccountLinkingConnection *_Nullable)getLinkedRetailerConnection: (BRAccountLinkingRetailer)retailer;
Swift
func getLinkedRetailerConnection(_ retailer: BRAccountLinkingRetailer) -> BRAccountLinkingConnection?
Parameters
retailer
The
BRAccountLinkingRetailer
retailer associated with the connectionReturn Value
A
BRAccountLinkingConnection*
objects -
Resets order history for a particular retailer
Declaration
Objective-C
- (void)resetHistoryForRetailer:(BRAccountLinkingRetailer)retailer;
Swift
func resetHistory(for retailer: BRAccountLinkingRetailer)
Parameters
retailer
The
BRAccountLinkingRetailer
retailer for which to reset the order history -
Resets order history for all linked accounts
Declaration
Objective-C
- (void)resetHistory;
Swift
func resetHistory()
-
Unlink a retailer online account
Declaration
Objective-C
- (void)unlinkAccountForRetailer:(BRAccountLinkingRetailer)retailer withCompletion:(nonnull void (^)(void))completion;
Swift
func unlinkAccount(for retailer: BRAccountLinkingRetailer) async
Parameters
retailer
The retailer for which to unlink the account
completion
Unlinking an account involves async operations involving cookies, so this completion indicates when those operations have completed
-
Unlink all accounts
Declaration
Objective-C
- (void)unlinkAllAccountsWithCompletion:(nonnull void (^)(void))completion;
Swift
func unlinkAllAccounts() async
Parameters
completion
Unlinking accounts involves async operations involving cookies, so this completion indicates when those operations have completed
-
Same as above except allows you to grab orders only for a single retailer
Declaration
Objective-C
- (BRAccountLinkingConnectionIdentifier *_Nullable) grabNewOrdersForRetailer:(BRAccountLinkingRetailer)retailer withCompletion:(nonnull void (^)(BRAccountLinkingRetailer, BRScanResults *_Nullable, NSInteger, UIViewController *_Nullable, BRAccountLinkingError, NSString *_Nonnull))completion;
Swift
func grabNewOrders(for retailer: BRAccountLinkingRetailer, withCompletion completion: @escaping (BRAccountLinkingRetailer, BRScanResults?, Int, UIViewController?, BRAccountLinkingError, String) -> Void) -> BRAccountLinkingConnectionIdentifier?
Return Value
A
BRAccountLinkingConnectionIdentifier*
object -
It cancels any connection that matches provided identifier
Declaration
Objective-C
- (void)cancelConnection: (nonnull BRAccountLinkingConnectionIdentifier *)identifier;
Swift
func cancelConnection(_ identifier: BRAccountLinkingConnectionIdentifier)
Parameters
identifier
A BRAccountLinkingConnectionIdentifier object
-
Updates linked connection with latest configuration
Declaration
Objective-C
- (void)updateConnection:(BRAccountLinkingConnection *_Nonnull)connection;
Swift
func update(_ connection: BRAccountLinkingConnection)
Parameters
connection
A BRAccountLinkingConnection object
-
It enables the SDK to check for new orders of all linked retailers periodically in backgorund, If background fetch is enabled by the host app
Note
The task is set to run every 1h but limittations apply. For more info, checkhttps://developer.apple.com/documentation/backgroundtasks/bgapprefreshtask?language=objc
Note
More info about how to generate the identifier string can be found here: https://developer.apple.com/documentation/uikit/app_and_environment/scenes/preparing_your_ui_to_run_in_the_background/using_background_tasks_to_update_your_app?language=objcNote
You must enable background fetch inside your application delegate’s didFinishLaunchingWithOptions: method. Attempting to enable it after launch or enabling it multiple times will cause a crashDeclaration
Objective-C
- (BRAccountLinkingError)enableBackgroundFetchWithIdentifier: (NSString *_Nonnull)identifier;
Swift
func enableBackgroundFetch(withIdentifier identifier: String) -> BRAccountLinkingError
Parameters
identifier
A string containing the identifier of the task.
Return Value
Any
BRAccountLinkingError
error that was encountered while attempting to enable background fetch