TelemetryDeck / SwiftSDK

Swift SDK for TelemetryDeck, a privacy-conscious analytics service for apps and websites.
https://telemetrydeck.com/
Other
148 stars 30 forks source link

Add a completion handler to TelemetryManager.send() #127

Open mjalq opened 8 months ago

mjalq commented 8 months ago

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

            }
        }

    }

`