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
| Method | Description |
|---|---|
+shared | Returns the singleton instance |
Properties
| Property | Description |
|---|---|
version | Current SDK version string |
backgroundFetchCompletion | Completion handler for background order fetch updates |
Methods
| Method | Description |
|---|---|
linkAccountWithConnection:withCompletion: | Links an account for a given retailer |
loginUserForLinkedRetailer:withCompletion: | Performs login for a linked retailer |
getLinkedConnections | Returns 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 orderBRAccountLinkingError error— any error encountered while attempting to grab ordersNSString *sessionId— a unique session GUID that can be reported for debugging purposesBRScanResults *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:
| Parameter | Description |
|---|---|
connection | A retailer's configuration object |
completion | Callback 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:
| Parameter | Description |
|---|---|
retailer | An ID of a linked retailer |
completion | Callback 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:
| Parameter | Description |
|---|---|
connection | The 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:
| Parameter | Description |
|---|---|
retailer | The retailer for which to unlink the account |
completion | Called 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:
| Parameter | Description |
|---|---|
identifier | A BRAccountLinkingConnectionIdentifier object |
updateConnection:
- (void)updateConnection:(BRAccountLinkingConnection *_Nonnull)connection;
func update(_ connection: BRAccountLinkingConnection)
Updates a linked connection with the latest configuration.
Parameters:
| Parameter | Description |
|---|---|
connection | A 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.
- 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
BGAppRefreshTaskdocumentation for setup details.
Parameters:
| Parameter | Description |
|---|---|
identifier | String containing the background task identifier |
Returns: Any BRAccountLinkingError encountered while enabling background fetch.