CNBBASMScanCodeImpl.m 1.27 KB
//
//  CNBBASMScanCodeImpl.m
//  CNLiveNetAdd
//
//  Created by CNLive on 2021/10/16.
//  Copyright © 2021 cnlive. All rights reserved.
//

#import "CNBBASMScanCodeImpl.h"
#import "CNBBASMScanViewController.h"

@implementation CNBBASMScanCodeImpl
RegisterBBASMAdapter()

+ (void)scanCode:(void(^)(NSString *result,TMNPBarcodeType type))callBack{
    CNBBASMScanViewController *ssVC = [[CNBBASMScanViewController alloc]
                                     initScanCompleteBlock:^(NSDictionary * _Nullable result,
                                                             NSError * _Nullable error) {
        // 扫描完成,回调传给callBack
        if (callBack) {
            if (error) {
                // 扫描失败,barcodeType为EMNPBarcodeType_NONE
                callBack(nil, EMNPBarcodeType_NONE);
            } else {
                // 扫描成功,barcodeType大于0,result就为扫描成功的结果
                NSString *scanResult = result[@"codeResult"];
                NSInteger scanType = [result[@"scanType"] integerValue];
                callBack(scanResult, scanType);
            }
        }
    }];
    
    UINavigationController *naVC = [Pyramid.bba_MNPUtilities getMNPNavigationController];
    [naVC pushViewController:ssVC animated:YES];
}
@end