iOS: support devkit change port

This commit is contained in:
pengfei.zhou 2023-08-11 17:30:32 +08:00 committed by jingpeng
parent e638c29ac3
commit 2e7fe08764
2 changed files with 18 additions and 6 deletions

View File

@ -322,8 +322,14 @@ - (void)input {
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
__strong typeof(_alert) alert = _alert;
NSString *ip = alert.textFields.lastObject.text;
[[DoricDev instance] connectDevKit:[NSString stringWithFormat:@"ws://%@:7777", ip]];
NSString *url = alert.textFields.lastObject.text;
if (![url containsString:@":"]) {
url = [NSString stringWithFormat:@"%@:7777", url];
}
if (![url containsString:@"://"]) {
url = [NSString stringWithFormat:@"ws://%@", url];
}
[[DoricDev instance] connectDevKit:url];
}];
[alert addAction:okAction];

View File

@ -101,10 +101,16 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:
[self.session stopRunning];
if ([metadataObjects count] >= 1) {
AVMetadataMachineReadableCodeObject *qrObject = [metadataObjects lastObject];
NSString *result = qrObject.stringValue;
NSLog(@"Scan result is %@", result);
[[DoricDev instance] connectDevKit:[NSString stringWithFormat:@"ws://%@:7777", result]];
ShowToast([NSString stringWithFormat:@"Connected to %@", result], DoricGravityBottom);
NSString *url = qrObject.stringValue;
NSLog(@"Scan result is %@", url);
if (![url containsString:@":"]) {
url = [NSString stringWithFormat:@"%@:7777", url];
}
if (![url containsString:@"://"]) {
url = [NSString stringWithFormat:@"ws://%@", url];
}
[[DoricDev instance] connectDevKit:url];
ShowToast([NSString stringWithFormat:@"Connected to %@", url], DoricGravityBottom);
[self.navigationController popViewControllerAnimated:NO];
}
}