BRScanManager

Objective-C

@interface BRScanManager : NSObject

Swift

class BRScanManager : NSObject

This is the main interface for initiating scanning sessions

Properties

  • Your BlinkReceipt license key

    Declaration

    Objective-C

    @property (nonatomic, strong, nonnull) NSString *licenseKey;

    Swift

    var licenseKey: String { get set }
  • Google Places Web Service API Key (for more info see: https://developers.google.com/places/web-service/get-api-key)

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) NSString *googlePlacesApiKey;

    Swift

    var googlePlacesApiKey: String? { get set }
  • Yelp API Key (for more infos see: https://www.yelp.com/developers)

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) NSString *yelpApiKey;

    Swift

    var yelpApiKey: String? { get set }
  • Your BlinkReceipt product intelligence key (if any)

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) NSString *prodIntelKey;

    Swift

    var prodIntelKey: String? { get set }
  • A client-specified identifier for the current user

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) NSString *clientUserId;

    Swift

    var clientUserId: String? { get set }
  • An array of NSString filepaths corresponding to the user images, if any, which were confirmed by the user during the scanning session.

    Declaration

    Objective-C

    @property (nonatomic, strong, nullable) NSArray<NSString *> *userFramesFilepaths;

    Swift

    var userFramesFilepaths: [String]? { get set }
  • If users should be able to correct historical receipts, this controls how long the receipt data will be stored locally to enable editing

    Default: 0 (indicates receipt data will not be stored locally)

    Declaration

    Objective-C

    @property (nonatomic) NSInteger daysToStoreReceiptData;

    Swift

    var daysToStoreReceiptData: Int { get set }
  • Indicates whether the current device is capable of processing video frames

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL deviceCanProcessVideo;

    Swift

    var deviceCanProcessVideo: Bool { get }

Class Methods

  • Always access this singleton instance

    Declaration

    Objective-C

    + (nonnull instancetype)sharedManager;

    Swift

    class func shared() -> Self

    Return Value

    The singleton instance

Methods

  • Initiates a static camera scanning experience (in which the user appears to be snapping static photos)

    Declaration

    Objective-C

    - (void)
        startStaticCameraFromController:(nonnull UIViewController *)viewController
                             cameraType:(BRCameraType)cameraType
                            scanOptions:(nullable BRScanOptions *)scanOptions
                           withDelegate:
                               (nonnull NSObject<BRScanResultsDelegate> *)delegate;

    Swift

    func startStaticCamera(from viewController: UIViewController, cameraType: BRCameraType, scanOptions: BRScanOptions?, with delegate: any BRScanResultsDelegate)

    Parameters

    viewController

    The parent view controller from which to display the camera controller modally

    cameraType

    User can choose to use standard (old) or enhanced (latest) camera UI

    scanOptions

    An instance of BRScanOptions specifying options for this scanning session

    delegate

    An instance conforming to BRScanResultsDelegate

  • Initiates a scanning session using your own subclass of BRCameraViewController which is presented as modal from the supplied UIViewController

    Declaration

    Objective-C

    - (void)startCustomCamera:(nonnull BRCameraViewController *)customController
               fromController:(nonnull UIViewController *)viewController
                  scanOptions:(nullable BRScanOptions *)scanOptions
                 withDelegate:(nonnull NSObject<BRScanResultsDelegate> *)delegate;

    Swift

    func startCustomCamera(_ customController: BRCameraViewController, from viewController: UIViewController, scanOptions: BRScanOptions?, with delegate: any BRScanResultsDelegate)

    Parameters

    customController

    Your custom subclass of BRCameraViewController

    viewController

    The parent view controller from which to display the camera controller modally

    scanOptions

    An instance of BRScanOptions specifying options for this scanning session

    delegate

    An instance conforming to BRScanResultsDelegate

  • Initiates a scanning session using your own subclass of BRCameraViewController which is pushed from the supplied UINavigationController

    Declaration

    Objective-C

    - (void)pushCustomCamera:(nonnull BRCameraViewController *)customController
           fromNavController:(nonnull UINavigationController *)navCon
                 scanOptions:(nullable BRScanOptions *)scanOptions
                withDelegate:(nonnull NSObject<BRScanResultsDelegate> *)delegate;

    Swift

    func pushCustomCamera(_ customController: BRCameraViewController, fromNavController navCon: UINavigationController, scanOptions: BRScanOptions?, with delegate: any BRScanResultsDelegate)

    Parameters

    customController

    Your custom subclass of BRCameraViewController

    navCon

    The navigation controller from which to push the camera controller

    scanOptions

    An instance of BRScanOptions specifying options for this scanning session

    delegate

    An instance conforming to BRScanResultsDelegate

  • Scans a PDF receipt

    Note: PDF max size is 10mb

    Declaration

    Objective-C

    - (void)scanPDFReceipt:(nonnull NSData *)pdfData
           withCountryCode:(nonnull NSString *)countryCode
            withCompletion:(nonnull void (^)(BRScanResults *_Nullable,
                                             NSError *_Nullable))completion;

    Swift

    func scanPDFReceipt(_ pdfData: Data, withCountryCode countryCode: String) async throws -> BRScanResults

    Parameters

    pdfData

    The raw PDF data

    countryCode

    Country of receipt

    completion

    This callback is invoked when the correction flow ends

    • BRScanResults *scanResults - If PDF parsing was successful, this will contain the parsed results
    • NSError *error - If PDF parsing failed, this will indicate the reason.
  • Creates a new MFMailComposeViewController populated with debug information about the most recent scan. Caller is responsible for setting the mailComposeDelegate and presenting/dismissing the view controller.

    Note: If this method is invoked on the simulator or a device with no email supported, it will output the message body to the console and return nil.

    Declaration

    Objective-C

    - (nonnull MFMailComposeViewController *)createMailControllerWithDebugInfo;

    Swift

    func createMailControllerWithDebugInfo() -> MFMailComposeViewController

    Return Value

    The controller to display

  • For purchase validation, use these properties to indicate the date a user activated a specific promotion

    Declaration

    Objective-C

    - (void)setActivationDate:(nonnull NSDate *)activationDate
                 forPromotion:(nonnull NSString *)promotionSlug;

    Swift

    func setActivationDate(_ activationDate: Date, forPromotion promotionSlug: String)

    Parameters

    activationDate

    The date on which the user activated this promotion

    promotionSlug

    The promotion slug as set up in the web PVP interface

  • Begin the receipt correction flow for a receipt stored on disk

    Declaration

    Objective-C

    - (void)startReceiptCorrection:(nonnull NSString *)blinkReceiptId
                fromViewController:(nonnull UIViewController *)vc
                   withCountryCode:(nullable NSString *)countryCode
                    withCustomFont:(nullable UIFont *)customFont
                    withCompletion:
                        (nullable void (^)(BRScanResults *_Nullable,
                                           NSError *_Nullable))completion;

    Swift

    func startReceiptCorrection(_ blinkReceiptId: String, from vc: UIViewController, withCountryCode countryCode: String?, withCustomFont customFont: UIFont?) async throws -> BRScanResults

    Parameters

    blinkReceiptId

    The receipt id of a receipt scanned within daysToStoreReceiptData days

    vc

    The view controller from which to show this modal

    countryCode

    Current country (this helps with barcode scanning)

    customFont

    Pass a non-null UIFont to style all of the elements in this flow

    completion

    This callback is invoked when the correction flow ends

    • BRScanResults *scanResults - Updated scan results object containing any changes the user made to the products (including adding new products) as well as an updated qualifiedPromotions array containing the results of the purchase validation call made after the user’s corrections
    • NSError *error - If the correction flow failed for any reason (such as being unable to find the passed receipt id record on disk) this parameter will be non-null
  • Retrieve resullts from disk or remotely for a specific receipt for custom user corrections flow

    Declaration

    Objective-C

    - (void)getResultsForReceiptCorrection:(nonnull NSString *)blinkReceiptId
                            withCompletion:
                                (nonnull void (^)(BRScanResults *_Nullable,
                                                  NSArray<UIImage *> *_Nonnull))
                                    completion;

    Swift

    func results(forReceiptCorrection blinkReceiptId: String) async -> (BRScanResults?, [UIImage])

    Parameters

    blinkReceiptId

    The receipt id to load from disk

    completion

    This callback is invoked once the SDK has attempted to retrieve results for this receipt

    • BRScanResults *results - The scan results associated with this blinkReceiptId
    • NSArray<UIImage*>* images - The images associated with this blinkReceiptId
  • After custom user correction flow, call this method to validate the new results against promotions

    Declaration

    Objective-C

    - (void)submitUpdatedResultsForValidation:(BRScanResults *_Nonnull)scanResults
                              withCountryCode:(nullable NSString *)countryCode
                               withCompletion:(nullable void (^)(
                                                  BRScanResults *_Nonnull,
                                                  NSError *_Nullable))completion;

    Swift

    func submitUpdatedResults(forValidation scanResults: BRScanResults, withCountryCode countryCode: String?) async throws -> BRScanResults

    Parameters

    scanResults

    The results object that was obtained from getResultsForReceiptCorrection:

    countryCode

    The country code to use for product intelligence on the updated results (default is @“US”)

    completion

    This callback is invoked once validation has been performed

    • BRScanResults *scanResults - Updated scan results object containing any changes the user made to the products (including adding new products) as well as an updated qualifiedPromotions array containing the results of the purchase validation call made after the user’s corrections
    • NSError *error - If any error occurred during validation this will be non-null
  • Retrieves targeted and general promotions for current user

    Declaration

    Objective-C

    - (void)getPromotionsWithCompletion:
        (nonnull void (^)(NSArray<BRPromotionInfo *> *_Nullable))completion;

    Swift

    func promotions() async -> [BRPromotionInfo]?

    Parameters

    completion

    This callback is invoked once promotions have been retrieved

    • NSArray<BRPromotionInfo*>* promos - An array of promotion info objects for the current user

  • Retrieves surveys for current user

    Declaration

    Objective-C

    - (void)getSurveysWithCompletion:
        (nonnull void (^)(NSArray<BRSurvey *> *_Nullable))completion;

    Swift

    func surveys() async -> [BRSurvey]?

    Parameters

    completion

    This callback is invoked once surveys have been retrieved

    • NSArray<BRSurvey*>* promos - An array of survey objects for the current user

  • Displays a given survey using the prepackaged flow

    Declaration

    Objective-C

    - (void)startSurvey:(nonnull BRSurvey *)survey
        fromViewController:(nonnull UIViewController *)viewController
            withCompletion:(nullable void (^)(BOOL))completion;

    Swift

    func start(_ survey: BRSurvey, from viewController: UIViewController) async -> Bool

    Parameters

    survey

    The survey to display

    viewController

    The view controller from which to display the survey

    completion

    This callback is invoked after the user has completed or cancelled the survey

    • BOOL cancelled - whether the user cancelled the survey or not

  • When displaying a survey using a custom UI, call this method after the user has completed the survey to post the results

    Declaration

    Objective-C

    - (void)submitSurveyResults:(nonnull BRSurvey *)survey;

    Swift

    func submitSurveyResults(_ survey: BRSurvey)

    Parameters

    survey

    This is the completed BRSurvey object containing the user’s responses