Skip to content

Commit 65dbd4b

Browse files
authored
feat(analytics,ios): add support for FirebaseAnalyticsWithoutAdIdSupport with SPM (#18061)
1 parent a6a0554 commit 65dbd4b

2 files changed

Lines changed: 32 additions & 1 deletion

File tree

docs/analytics/_get-started.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,32 @@ await FirebaseAnalytics.instance
8383
);
8484
```
8585
86+
## Using Analytics without Ad ID support (iOS) {:#without-ad-id}
87+
88+
If your app doesn't use IDFA, you can use `FirebaseAnalyticsWithoutAdIdSupport`
89+
instead of the default `FirebaseAnalytics` iOS dependency to avoid App Store
90+
review questions about advertising identifiers.
91+
92+
### Swift Package Manager
93+
94+
Set the `FIREBASE_ANALYTICS_WITHOUT_ADID` environment variable when building:
95+
96+
```bash
97+
FIREBASE_ANALYTICS_WITHOUT_ADID=true flutter build ios
98+
```
99+
100+
You can also add this variable to your Xcode scheme's environment variables
101+
for persistent configuration.
102+
103+
### CocoaPods
104+
105+
Add this to your app's `Podfile`:
106+
107+
```ruby
108+
pod 'FirebaseAnalytics', :modular_headers => true
109+
pod 'FirebaseAnalyticsWithoutAdIdSupport', :modular_headers => true
110+
```
111+
86112
## Next steps
87113

88114
* Use the [DebugView](/docs/analytics/debugview) to verify your events.

packages/firebase_analytics/firebase_analytics/ios/firebase_analytics/Package.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ guard let shared_spm_version = Version("\(firebase_core_version_string)\(shared_
7979
fatalError("Invalid firebase_core version: \(firebase_core_version_string)\(shared_spm_tag)")
8080
}
8181

82+
// Set FIREBASE_ANALYTICS_WITHOUT_ADID=true to use FirebaseAnalyticsWithoutAdIdSupport
83+
// e.g. FIREBASE_ANALYTICS_WITHOUT_ADID=true flutter build ios
84+
let useWithoutAdId = ProcessInfo.processInfo.environment["FIREBASE_ANALYTICS_WITHOUT_ADID"] != nil
85+
let analyticsProduct = useWithoutAdId ? "FirebaseAnalyticsWithoutAdIdSupport" : "FirebaseAnalytics"
86+
8287
let package = Package(
8388
name: "firebase_analytics",
8489
platforms: [
@@ -95,7 +100,7 @@ let package = Package(
95100
.target(
96101
name: "firebase_analytics",
97102
dependencies: [
98-
.product(name: "FirebaseAnalytics", package: "firebase-ios-sdk"),
103+
.product(name: analyticsProduct, package: "firebase-ios-sdk"),
99104
// Wrapper dependency
100105
.product(name: "firebase-core-shared", package: "flutterfire"),
101106
],

0 commit comments

Comments
 (0)