Solved but not using the picker ;-)
I use auto-reconnection from the external accessory. No need to show the picker, if once connected.
Post
Replies
Boosts
Views
Activity
Thanks, eskimo!
I have tied the timer which works.
But since in the application this problem only appears in a kind of connection test process I decided to start the connection and show an ALERT with CANCEL button. The ALERT will be closed on reaching .cancelled state. Connection is cancelled on state .ready, .waiting and .failure as well as when CANCEL is pressed. The I inform the main thread about the result by a Notification:
if alert == nil {
alert = UIAlertController(title: "Test connection", message: "Please wait...", preferredStyle: .alert)
if let alert = alert {
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { action in
self.testConnection.forceCancel()
NotificationCenter.default.post(name: Notification.Name("connectionTest"), object: "Canceled by user!")
self.alert = nil
return
}))
let loadingIndicator = UIActivityIndicatorView(frame: CGRect(x: 10, y: 5, width: 50, height: 50))
loadingIndicator.hidesWhenStopped = true
loadingIndicator.style = UIActivityIndicatorView.Style.medium
loadingIndicator.startAnimating()
alert.view.addSubview(loadingIndicator)
present(alert, animated: false, completion: nil)
}
}
}
If your app is able to run in the background you can trigger the getTimeline by using
WidgetCenter.shared.reloadTimelines(ofKind:)
In my app I can trigger the widget every second.
Thanks OOPer,
this I had tried, but it seem that this is a timeout for the established TCP-connection, but I am one layer above in which the server is not answering because the port is wrong....