Skip to main content

BRAccountLinkingManager

Manages users' linked retailer accounts for parsing e-receipts. The basic workflow involves capturing user credentials, storing them, grabbing new orders, and retrieving order details. Inherits from NSObject.

SDK Version: 3.2.0

Declaration

@interface BRAccountLinkingManager : NSObject
class BRAccountLinkingManager : NSObject

Quick Reference

Class Methods

MethodDescription
+sharedReturns the singleton instance

Properties

PropertyDescription
versionCurrent SDK version string
backgroundFetchCompletionCompletion handler for background order fetch updates

Methods

MethodDescription
linkAccountWithConnection:withCompletion:Links an account for a given retailer
loginUserForLinkedRetailer:withCompletion:Performs login for a linked retailer
getLinkedConnectionsReturns all linked account connections on the device
resetHistoryForConnection:Resets order history for a connection
unlinkAccountForRetailer:withCompletion:Unlinks a retailer account
grabNewOrdersForRetailer:withCompletion:Fetches new orders for a single retailer
cancelConnection:Cancels an in-progress connection task
updateConnection:Updates a linked connection with new configuration
enableBackgroundFetchWithIdentifier:Enables periodic background order checking

Class Methods

+shared

+ (nonnull instancetype)shared;
class func shared() -> Self

Returns the singleton instance of BRAccountLinkingManager.


Properties

version (read-only)

@property (nonatomic, copy, readonly, nonnull) NSString *version;
var version: String { get }

Returns the current SDK version string.


backgroundFetchCompletion

@property (nonatomic, copy, nullable) void (^)(BRAccountLinkingRetailer,
BRAccountLinkingError, NSString *_Nullable, BRScanResults *_Nullable)
backgroundFetchCompletion;
var backgroundFetchCompletion: ((BRAccountLinkingRetailer,
BRAccountLinkingError, String?, BRScanResults?) -> Void)? { get set }

A completion handler to receive updates from a background operation when enabled via enableBackgroundFetchWithIdentifier:. Receives:

  • BRAccountLinkingRetailer retailer — the retailer for this order
  • BRAccountLinkingError error — any error encountered while attempting to grab orders
  • NSString *sessionId — a unique session GUID that can be reported for debugging purposes
  • BRScanResults *results — the current order

Methods

linkAccountWithConnection:withCompletion:

- (BRAccountLinkingConnectionIdentifier *_Nullable)
linkAccountWithConnection:(BRAccountLinkingConnection *_Nonnull)connection
withCompletion:(nonnull void (^)(BRAccountLinkingError,
UIViewController *_Nullable,
NSString *_Nullable))completion;
func linkAccount(with connection: BRAccountLinkingConnection,
withCompletion completion: @escaping (BRAccountLinkingError,
UIViewController?, String?) -> Void) -> BRAccountLinkingConnectionIdentifier?

Links an account for a given retailer.

Parameters:

ParameterDescription
connectionA retailer's configuration object
completionCallback executed when additional user input is needed or linking completes. Receives an error status, an optional view controller for 2FA/user interaction, and a session ID.

Returns: A BRAccountLinkingConnectionIdentifier that can be used to cancel the task.


loginUserForLinkedRetailer:withCompletion:

- (BRAccountLinkingConnectionIdentifier *_Nullable)
loginUserForLinkedRetailer:(BRAccountLinkingRetailer)retailer
withCompletion:(nonnull void (^)(BRAccountLinkingError,
UIViewController *_Nullable,
NSString *_Nullable))completion;
func loginUser(forLinkedRetailer retailer: BRAccountLinkingRetailer,
withCompletion completion: @escaping (BRAccountLinkingError,
UIViewController?, String?) -> Void) -> BRAccountLinkingConnectionIdentifier?

Performs a login for the provided retailer. Check isAuthenticated on the connection before calling this method.

Parameters:

ParameterDescription
retailerAn ID of a linked retailer
completionCallback with error status, an optional view controller, and a session ID

Returns: A BRAccountLinkingConnectionIdentifier for task cancellation.


getLinkedConnections

- (NSArray<BRAccountLinkingConnection *> *_Nonnull)getLinkedConnections;
func getLinkedConnections() -> [BRAccountLinkingConnection]

Returns a list of connections matching all linked accounts on the device.

Returns: An array of BRAccountLinkingConnection objects.


resetHistoryForConnection:

- (void)resetHistoryForConnection:(BRAccountLinkingConnection *_Nonnull)connection;
func resetHistory(for connection: BRAccountLinkingConnection)

Resets order history for a particular account connection.

Parameters:

ParameterDescription
connectionThe connection for which to reset order history

unlinkAccountForRetailer:withCompletion:

- (void)unlinkAccountForRetailer:(BRAccountLinkingRetailer)retailer
withCompletion:(nonnull void (^)(void))completion;
func unlinkAccount(for retailer: BRAccountLinkingRetailer) async

Unlinks a retailer online account.

Parameters:

ParameterDescription
retailerThe retailer for which to unlink the account
completionCalled when async cookie operations complete

grabNewOrdersForRetailer:withCompletion:

- (BRAccountLinkingConnectionIdentifier *_Nullable)
grabNewOrdersForRetailer:(BRAccountLinkingRetailer)retailer
withCompletion:(nonnull void (^)(BRAccountLinkingRetailer,
BRScanResults *_Nullable,
NSInteger,
UIViewController *_Nullable,
BRAccountLinkingError,
NSString *_Nonnull))completion;
func grabNewOrders(for retailer: BRAccountLinkingRetailer,
withCompletion completion: @escaping (BRAccountLinkingRetailer,
BRScanResults?, Int, UIViewController?, BRAccountLinkingError,
String) -> Void) -> BRAccountLinkingConnectionIdentifier?

Grabs orders for a single retailer only.

Returns: A BRAccountLinkingConnectionIdentifier object.


cancelConnection:

- (void)cancelConnection:(nonnull BRAccountLinkingConnectionIdentifier *)identifier;
func cancelConnection(_ identifier: BRAccountLinkingConnectionIdentifier)

Cancels any connection matching the provided identifier.

Parameters:

ParameterDescription
identifierA BRAccountLinkingConnectionIdentifier object

updateConnection:

- (void)updateConnection:(BRAccountLinkingConnection *_Nonnull)connection;
func update(_ connection: BRAccountLinkingConnection)

Updates a linked connection with the latest configuration.

Parameters:

ParameterDescription
connectionA BRAccountLinkingConnection object

enableBackgroundFetchWithIdentifier:

- (BRAccountLinkingError)enableBackgroundFetchWithIdentifier:(NSString *_Nonnull)identifier;
func enableBackgroundFetch(withIdentifier identifier: String) -> BRAccountLinkingError

Enables the SDK to check for new orders of all linked retailers periodically in the background, if background fetch is enabled by the host app.

note
  • Tasks run approximately every 1 hour with system-imposed limitations.
  • Host apps must enable background fetch in application(_:didFinishLaunchingWithOptions:).
  • Calling this method multiple times or after app launch may cause crashes.
  • See Apple's BGAppRefreshTask documentation for setup details.

Parameters:

ParameterDescription
identifierString containing the background task identifier

Returns: Any BRAccountLinkingError encountered while enabling background fetch.