|
|
//
|
|
|
// YH_QRCodeHelper.m
|
|
|
// YH_Mall
|
|
|
// QRNativeConfig.m
|
|
|
// YH_Vendor
|
|
|
//
|
|
|
// Created by redding on 16/8/29.
|
|
|
// Copyright © 2016年 YOHO. All rights reserved.
|
|
|
// Created by 孙凯 on 2017/6/16.
|
|
|
// Copyright © 2017年 Facebook. All rights reserved.
|
|
|
//
|
|
|
|
|
|
#import "YH_QRCodeHelper.h"
|
|
|
#import "QRNativeConfig.h"
|
|
|
#import "RCTEventDispatcher.h"
|
|
|
#import "YH_AVScanViewController.h"
|
|
|
#import "AppDelegate.h"
|
|
|
|
|
|
@implementation YH_QRCodeHelper
|
|
|
@implementation QRNativeConfig
|
|
|
|
|
|
@synthesize bridge = _bridge;
|
|
|
|
|
|
RCT_EXPORT_MODULE()
|
|
|
|
|
|
|
|
|
RCT_REMAP_METHOD(displayQRScanner, displayQRScannerWithResolver:(RCTPromiseResolveBlock)resolve
|
|
|
rejecter:(RCTPromiseRejectBlock)reject) {
|
|
|
RCT_EXPORT_METHOD(startScanQRCode) {
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
YH_AVScanViewController *avscanViewController = [[YH_AVScanViewController alloc] init];
|
|
|
avscanViewController.scanType = YHScanType_Express;
|
|
|
[avscanViewController.view setFrame:[[UIScreen mainScreen] bounds]];
|
|
|
avscanViewController.resultCallBack = ^(NSString *info) {
|
|
|
resolve(info);
|
|
|
};
|
|
|
YH_AVScanViewController *avscanViewController = [[YH_AVScanViewController alloc] init];
|
|
|
avscanViewController.scanType = YHScanType_Express;
|
|
|
[avscanViewController.view setFrame:[[UIScreen mainScreen] bounds]];
|
|
|
avscanViewController.resultCallBack = ^(NSString *info) {
|
|
|
|
|
|
[self.bridge.eventDispatcher sendAppEventWithName:@"scanQRComplete"
|
|
|
body:info];
|
|
|
};
|
|
|
|
|
|
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
|
|
[delegate.window.rootViewController presentViewController:avscanViewController animated:YES completion:^{}];
|
|
|
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
|
|
|
[delegate.window.rootViewController presentViewController:avscanViewController animated:YES completion:^{}];
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
|