session-ios/Signal/src/view controllers/ScanIdentityBarcodeViewController.m
Michael Kirk 84156698c4 Provision device from QRCode.
NEEDS DESIGN - will likely have an intermediate "device manager" screen.

* extracted QRCode Scanner into re-usable ViewController

// FREEBIE
2016-09-02 12:40:21 -04:00

53 lines
1.8 KiB
Objective-C

//
// ScanIdentityBarcodeViewController.m
// Signal-iOS
//
// Created by Christine Corbett Moran on 3/29/14.
// Copyright (c) 2014 Open Whisper Systems. All rights reserved.
//
#import "ScanIdentityBarcodeViewController.h"
#import "NSData+Base64.h"
@implementation ScanIdentityBarcodeViewController
- (void)didDetectQRCodeWithString:(NSString *)string
{
NSData *data = [NSData dataFromBase64String:string];
NSString *dialogTitle;
NSString *dialogDescription;
if ([data isEqualToData:self.identityKey]) {
dialogTitle = NSLocalizedString(@"SCAN_KEY_VERIFIED_TITLE", @"");
dialogDescription = NSLocalizedString(@"SCAN_KEY_VERIFIED_TEXT", @"");
} else {
dialogTitle = NSLocalizedString(@"SCAN_KEY_CONFLICT_TITLE", @"");
dialogDescription = NSLocalizedString(@"SCAN_KEY_CONFLICT_TEXT", @"");
}
UIAlertController *controller = [UIAlertController alertControllerWithTitle:dialogTitle
message:dialogDescription
preferredStyle:UIAlertControllerStyleAlert];
[self
presentViewController:controller
animated:YES
completion:^{
[self performSelector:@selector(dismissScannerAfterSuccesfullScan) withObject:nil afterDelay:5];
}];
}
#pragma mark - Action
- (void)dismissScannerAfterSuccesfullScan {
[self dismissViewControllerAnimated:YES
completion:^{
[self closeButtonAction:nil];
}];
}
- (IBAction)closeButtonAction:(id)sender {
[self performSegueWithIdentifier:@"UnwindToIdentityKeyWasVerifiedSegue" sender:self];
}
@end