Skip to content

fix: fix timing issue in idfa #125

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

Merged
merged 3 commits into from
Mar 14, 2022
Merged
Changes from 1 commit
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
18 changes: 13 additions & 5 deletions Examples/other_plugins/IDFACollection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,11 @@ import AppTrackingTransparency
class IDFACollection: Plugin {
let type = PluginType.enrichment
var analytics: Analytics? = nil
@Atomic private var alreadyAsked = false

func execute<T: RawEvent>(event: T?) -> T? {
let status = ATTrackingManager.trackingAuthorizationStatus
if status == .notDetermined {
// we don't know, so should ask the user.
askForPermission()
}


let trackingStatus = statusToString(status)
var idfa = fallbackValue
var adTrackingEnabled = false
Expand All @@ -77,6 +74,17 @@ class IDFACollection: Plugin {
}
}

extension IDFACollection: iOSLifecycle {
func applicationDidBecomeActive(application: UIApplication?) {
let status = ATTrackingManager.trackingAuthorizationStatus
if status == .notDetermined && !alreadyAsked {
// we don't know, so should ask the user.
askForPermission()
alreadyAsked = true
}
}
}

extension IDFACollection {
var fallbackValue: String? {
get {
Expand Down