From 1612716103a48b43c464911d81cf3ca4ec88be77 Mon Sep 17 00:00:00 2001 From: Dan Hillman Date: Thu, 3 Mar 2022 04:25:13 +0000 Subject: [PATCH] =?UTF-8?q?Updated=20iOS=20CHIP=20tool=20README=20and=20qr?= =?UTF-8?q?=20scanner=20to=20indicate=20requirement=20>=E2=80=A6=20(#15715?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Updated iOS CHIP tool README and qr scanner to indicate requirement >= iOS 15.4 (#15640) * Restyled by clang-format * Restyled by prettier-markdown Co-authored-by: Restyled.io --- .../View Controllers/RootViewController.m | 32 ++++++++++++++++--- src/darwin/CHIPTool/README.md | 8 +++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/RootViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/RootViewController.m index 4f40582ae8f295..54fd0d4efc9925 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/RootViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/RootViewController.m @@ -70,7 +70,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath [tableView deselectRowAtIndexPath:indexPath animated:YES]; switch (indexPath.row) { case 0: - [self pushQRCodeScanner]; + [self pushQRCodeScannerWithSkipCheck:NO]; break; case 1: [self pushEnumeration]; @@ -125,10 +125,34 @@ - (void)pushNetworkConfiguration [self.navigationController pushViewController:controller animated:YES]; } -- (void)pushQRCodeScanner +- (void)pushQRCodeScannerWithSkipCheck:(BOOL)skipIosCheck { - QRCodeViewController * controller = [QRCodeViewController new]; - [self.navigationController pushViewController:controller animated:YES]; + if (skipIosCheck) { + QRCodeViewController * controller = [QRCodeViewController new]; + [self.navigationController pushViewController:controller animated:YES]; + } else { + if (@available(iOS 15.4, *)) { + // Device using the required iOS version (>= 15.4) + [self pushQRCodeScannerWithSkipCheck:YES]; + } else { + // Device NOT using the required iOS version (< 15.4) + // Show a warning, but let the user continue + UIAlertController * alertController = + [UIAlertController alertControllerWithTitle:@"Warning" + message:@"QRCode scanner to pair a matter device requires iOS >= 15.4" + preferredStyle:UIAlertControllerStyleAlert]; + __weak typeof(self) weakSelf = self; + [alertController addAction:[UIAlertAction actionWithTitle:@"I understand" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction * action) { + typeof(self) strongSelf = weakSelf; + if (strongSelf) { + [strongSelf pushQRCodeScannerWithSkipCheck:YES]; + } + }]]; + [self presentViewController:alertController animated:YES completion:nil]; + } + } } - (void)pushEnumeration diff --git a/src/darwin/CHIPTool/README.md b/src/darwin/CHIPTool/README.md index 904ca30c48e2ff..2a15cb027d9701 100644 --- a/src/darwin/CHIPTool/README.md +++ b/src/darwin/CHIPTool/README.md @@ -13,6 +13,14 @@ control. --- +## Prerequisites + +- Requires building and running the app to a physical device on iOS >= 15.4. + - At time of writing 15.4 is in beta and the current active iOS version is + 15.3.1. For detailed instructions on how to install the iOS 15.4 beta + onto your device visit + [beta.apple.com](https://beta.apple.com/sp/betaprogram/enroll#ios) + ## Building the Application CHIPTool iOS can be built with the latest Xcode releases.