A simple escaping completion handler would suffice.
This would be useful if I want the app to send one signal per day at most, while making sure that the signal was received by the server before blocking further attempts.
`
if lastSignalSentDate != today {
TelemetryManager.send("appUsed")
//If the above line fails due to poor internet or an offline launch of the app, we have no way of knowing.
lastSignalSentDate = today
}
`
Purposed solution
`
if lastSignalSentDate != today {
TelemetryManager.send("appUsed") { didFail in
if !didFail {
lastSignalSentDate = today
}
}
}
A simple escaping completion handler would suffice.
This would be useful if I want the app to send one signal per day at most, while making sure that the signal was received by the server before blocking further attempts.
`
`
Purposed solution
`
`