Skip to content

Commit

Permalink
fix: remove idfv fallback for idfa plugin (#942)
Browse files Browse the repository at this point in the history
* fix: remove idfv fallback for idfa plugin

* fix: refactor to check status only
  • Loading branch information
ashton-huxtable authored May 20, 2024
1 parent 4cbb4e8 commit ca6ee10
Showing 1 changed file with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,28 @@ class AnalyticsReactNativePluginIdfa: NSObject {
) -> Void {
if #available(iOS 14, *) {
ATTrackingManager.requestTrackingAuthorization { status in
let idfa = status == .authorized ? ASIdentifierManager.shared().advertisingIdentifier.uuidString : self.fallbackValue
resolve([
"adTrackingEnabled": status == .authorized,
"advertisingId": idfa!,
"trackingStatus": self.statusToString(status)
])
if status == .authorized {
let idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString
resolve([
"adTrackingEnabled": status == .authorized,
"advertisingId": idfa,
"trackingStatus": self.statusToString(status)
])
} else {
resolve([
"adTrackingEnabled": false,
"trackingStatus": self.statusToString(status)
])
}
}
} else {
let adTrackingEnabled: Bool = true
let trackingStatus: String = "authorized"
let idfa = adTrackingEnabled ? ASIdentifierManager.shared().advertisingIdentifier.uuidString : fallbackValue
let idfa = ASIdentifierManager.shared().advertisingIdentifier.uuidString

let context: [String: Any] = [
"adTrackingEnabled": adTrackingEnabled,
"advertisingId": idfa!,
"advertisingId": idfa,
"trackingStatus": trackingStatus
]

Expand All @@ -40,14 +47,6 @@ class AnalyticsReactNativePluginIdfa: NSObject {
}
}

var fallbackValue: String? {
get {
// fallback to the IDFV value.
// this is also sent in event.context.device.id,
// feel free to use a value that is more useful to you.
return UIDevice.current.identifierForVendor?.uuidString
}
}

@available(iOS 14, *)
func statusToString(_ status: ATTrackingManager.AuthorizationStatus) -> String {
Expand All @@ -66,4 +65,4 @@ class AnalyticsReactNativePluginIdfa: NSObject {
}
return result
}
}
}

0 comments on commit ca6ee10

Please sign in to comment.