Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crashes during BLE and Wifi provisioning #44

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions apps/ios/DuoApp/DuoApp/DuoBLEProvisionTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class DuoBLEProvisionTableViewController: UITableViewController, UIPopoverPresen
ssidTextField = textField
});

self.ssidAlertAction = UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_OK"), style: UIAlertActionStyle.default, handler: { (action) -> Void in
let ssidAlertAction = UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_OK"), style: UIAlertActionStyle.default, handler: { (action) -> Void in


func secHandler(_ action:UIAlertAction) {
Expand All @@ -259,7 +259,7 @@ class DuoBLEProvisionTableViewController: UITableViewController, UIPopoverPresen

let passAlert = UIAlertController(title: Settings.sharedInstance.getLocalizedString("ENTER_WIFI_CREDENTIAL"), message: Settings.sharedInstance.getLocalizedString("ENTER_WIFI_CREDENTIAL_MSG"), preferredStyle:.alert)

self.passAlertAction = UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_OK"), style: UIAlertActionStyle.default, handler: { (action) -> Void in
let passAlertAction = UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_OK"), style: UIAlertActionStyle.default, handler: { (action) -> Void in

let ssid = ssidTextField?.text
let password = passwordTextField?.text
Expand All @@ -275,13 +275,14 @@ class DuoBLEProvisionTableViewController: UITableViewController, UIPopoverPresen
passwordTextField = textField
})

self.passAlertAction?.isEnabled = false

passAlert.addAction(UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_CANCEL"), style: UIAlertActionStyle.cancel, handler: { (action) -> Void in
SVProgressHUD.dismiss()
}))

passAlert.addAction(self.passAlertAction!)
passAlertAction.isEnabled = false
passAlert.addAction(passAlertAction)
self.passAlertAction = passAlertAction



Expand Down Expand Up @@ -311,8 +312,9 @@ class DuoBLEProvisionTableViewController: UITableViewController, UIPopoverPresen
// SVProgressHUD.showWithStatus(Settings.sharedInstance.getLocalizedString("AP_CONNECTING") + "\(ap.ssid)...")
// self.duo.setAPInfo(ap, password: password!)
})
self.ssidAlertAction!.isEnabled = false
alert.addAction(self.ssidAlertAction!)
ssidAlertAction.isEnabled = false
alert.addAction(ssidAlertAction)
self.ssidAlertAction = ssidAlertAction

alert.addAction(UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_CANCEL"), style: UIAlertActionStyle.cancel, handler: { (action) -> Void in
SVProgressHUD.dismiss()
Expand All @@ -336,7 +338,7 @@ class DuoBLEProvisionTableViewController: UITableViewController, UIPopoverPresen
inputTextField = textField
})

self.passAlertAction = UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_OK"), style: UIAlertActionStyle.default, handler: { (action) -> Void in
let passAlertAction = UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_OK"), style: UIAlertActionStyle.default, handler: { (action) -> Void in

let password = inputTextField?.text
SVProgressHUD.show(withStatus: Settings.sharedInstance.getLocalizedString("AP_CONNECTING") + "\(ap.ssid)...")
Expand All @@ -349,8 +351,9 @@ class DuoBLEProvisionTableViewController: UITableViewController, UIPopoverPresen



self.passAlertAction?.isEnabled = false
alert.addAction(self.passAlertAction!)
passAlertAction.isEnabled = false
alert.addAction(passAlertAction)
self.passAlertAction = passAlertAction

self.present(alert, animated: true, completion: nil)

Expand Down
27 changes: 13 additions & 14 deletions apps/ios/DuoApp/DuoApp/DuoWifiProvisioningViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ class DuoWifiProvisioningViewController: UITableViewController, StreamDelegate,
});


self.ssidAlertAction = UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_OK"), style: UIAlertActionStyle.default, handler: { (action) -> Void in
let ssidAlertAction = UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_OK"), style: UIAlertActionStyle.default, handler: { (action) -> Void in


func secHandler(_ action:UIAlertAction) {
Expand Down Expand Up @@ -576,7 +576,7 @@ class DuoWifiProvisioningViewController: UITableViewController, StreamDelegate,
passwordTextField = textField
})

self.passAlertAction = UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_OK"), style: UIAlertActionStyle.default, handler: { (action) -> Void in
let passAlertAction = UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_OK"), style: UIAlertActionStyle.default, handler: { (action) -> Void in

let ssid = ssidTextField?.text
let password = passwordTextField?.text
Expand All @@ -588,10 +588,11 @@ class DuoWifiProvisioningViewController: UITableViewController, StreamDelegate,
passAlert.addAction(UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_CANCEL"), style: UIAlertActionStyle.cancel, handler: { (action) -> Void in
SVProgressHUD.dismiss()
}))


self.passAlertAction?.isEnabled = false
passAlert.addAction(self.passAlertAction!)
passAlertAction.isEnabled = false
passAlert.addAction(passAlertAction)
self.passAlertAction = passAlertAction

self.present(passAlert, animated: true, completion: nil)
}
else {
Expand Down Expand Up @@ -619,15 +620,14 @@ class DuoWifiProvisioningViewController: UITableViewController, StreamDelegate,
// SVProgressHUD.showWithStatus(Settings.sharedInstance.getLocalizedString("AP_CONNECTING") + "\(ap.ssid)...")
// self.duo.setAPInfo(ap, password: password!)
})
self.ssidAlertAction!.isEnabled = false

alert.addAction(UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_CANCEL"), style: UIAlertActionStyle.cancel, handler: { (action) -> Void in
SVProgressHUD.dismiss()
}))


alert.addAction(self.ssidAlertAction!)

ssidAlertAction.isEnabled = false
alert.addAction(ssidAlertAction)
self.ssidAlertAction = ssidAlertAction

self.present(alert, animated: true, completion: nil)
tableView.deselectRow(at: indexPath, animated: false)
Expand All @@ -649,7 +649,7 @@ class DuoWifiProvisioningViewController: UITableViewController, StreamDelegate,
textField.isSecureTextEntry = true
inputTextField = textField
})
self.passAlertAction = UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_OK"), style: UIAlertActionStyle.default, handler: { (action) -> Void in
let passAlertAction = UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_OK"), style: UIAlertActionStyle.default, handler: { (action) -> Void in

let password = inputTextField?.text
SVProgressHUD.show(withStatus: Settings.sharedInstance.getLocalizedString("AP_CONNECTING") + "\(ap.ssid)...")
Expand All @@ -659,11 +659,10 @@ class DuoWifiProvisioningViewController: UITableViewController, StreamDelegate,
alert.addAction(UIAlertAction(title: Settings.sharedInstance.getLocalizedString("RBDUO_CANCEL"), style: UIAlertActionStyle.default, handler: { (action) -> Void in
SVProgressHUD.dismiss()
}))


self.passAlertAction?.isEnabled = false
alert.addAction(self.passAlertAction!)

passAlertAction.isEnabled = false
alert.addAction(passAlertAction)
self.passAlertAction = passAlertAction

self.present(alert, animated: true, completion: nil)

Expand Down