Reputation: 567
I have a Device Firmware Update view where I update the physical devices' firmware.
My goal is to show the alert when the DFU state is .completed
. That means I want to bind the alert popup to the state, not to the action.
Here is what I have so far:
func showDFUCompletedAlert() {
let dfuAlert = UIAlertController(title: "The device firmware is updated successfully.", message: "You will be redirected back to the Devices list. To get back to your device just tap on it without refreshing Devices list.", preferredStyle: .alert)
dfuAlert.addAction(UIAlertAction(title: "OK", style: .default, handler: {_ in
self.dfuUpdate = nil
}))
self.present(dfuAlert, animated: true)
}
So, the question is: how do I show the alert right after the device firmware update is completed without tapping on the buttons etc?
Thanks!
UPDATE: Adding the code of the DFU States:
func dfuStateDidChange(to state: DFUState) {
print(state.description())
case .connecting:
self.updateView?.selectButton.isHidden = true
case .starting:
self.updateView?.selectButton.isHidden = true
case .aborted:
self.updateView?.selectButton.isHidden = false
self.updateView?._fileURL = nil
self.updateView?.fileNameLabel.text = "Select file"
case .completed:
supportDelegate?.showDFUCompletedAlert()
}
UPDATE [2]: Breakpoint report:
libsystem_kernel.dylib`mach_msg_trap:
0x18f63c0ec <+0>: mov x16, #-0x1f
0x18f63c0f0 <+4>: svc #0x80
-> 0x18f63c0f4 <+8>: ret
Upvotes: 0
Views: 144
Reputation: 844
As we found out in comments, you forget to set the delegates for your controller, and the showDFUCompletedAlert()
method didn't run.
Upvotes: 2