-
Notifications
You must be signed in to change notification settings - Fork 316
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
[CF-106] Fetch AdServices Token #1519
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
f3131f9
Add new configuration option automaticAdServicesAttributionTokenColle…
d322c7c
Add postAdServicesTokenIfNeeded, call in same places as old iAD calls
dbcdc4c
Fetch and post ad services token
c557ba5
Fix incorrect available check
882a936
Pull discount string from attribution strings to StoreKitStrings
21aa633
Merge branch 'main' into ad-services
cc93cdb
fetching unit tests
9706097
formatting/renaming
c98031a
Remove code for fetching
03357e7
Use canImport
bcd58a2
Update availability checks, move to Deprecations.swift
5c957b7
Merge branch 'ad-services' of github.com:RevenueCat/purchases-ios int…
4c6332c
Remove some todos, fix formatting
4a952c4
fix lint
3811408
fix mockattributionfetcher
e02c0d2
API testers
81f2628
Merge branch 'ad-services-sdk' into ad-services
47ecfff
move rest of deprecations to deprecations.swift
d51c37f
Add comment about OS availability
f2014f8
Revert "move rest of deprecations to deprecations.swift"
8923389
Add explicit integer values for attribution networks
e5dea3a
Fix deprecation warning ...
10a073b
update fastlane
352de9e
Revert "Fix deprecation warning ..."
bae8e3c
skipping setting properties on de-init
d4a552a
Update docc and AttributionNetwork api tester
c181dc7
Remove iad code
f29aedb
deprecate attributionnetwork enum value
d6d3dc7
remove superfluous lint disable
67b3e7a
remove iad-associated unit tests
4d800ac
Merge branch 'ad-services-sdk' into ad-services
2b21373
fix more unit tests
61c28a3
Fix bad merges
26b02f7
remove PostAttributionDataOperation and AfficheClientProxy
a11742a
Make adServicesToken a var
6a7697b
use do catch, more details in error log
60db73b
formatting
1df28a0
Update Sources/Purchasing/Purchases.swift
3e3d383
linking optional
cc98cbe
directly return
839bc8d
`CustomerInfo`: moved deprecated property to `Deprecations` (#1549)
NachoSoto 2c16386
make error not optional
42bbabc
Merge branch 'main' into ad-services
3de0061
Add AdServices.framework to APITesters
joshdholtz d9f757b
Don't link `AdServices.framework` on `watchOS` & `tvOS` (#1554)
NachoSoto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,6 @@ class AttributionPoster { | |
self.subscriberAttributesManager = subscriberAttributesManager | ||
} | ||
|
||
// swiftlint:disable:next function_body_length | ||
func post(attributionData data: [String: Any], | ||
fromNetwork network: AttributionNetwork, | ||
networkUserId: String?) { | ||
|
@@ -88,46 +87,27 @@ class AttributionPoster { | |
} | ||
|
||
if !newData.isEmpty { | ||
if network == .appleSearchAds { | ||
postSearchAds(newData: newData, | ||
network: network, | ||
appUserID: currentAppUserID, | ||
newDictToCache: newDictToCache) | ||
} else { | ||
postSubscriberAttributes(newData: newData, | ||
network: network, | ||
appUserID: currentAppUserID, | ||
newDictToCache: newDictToCache) | ||
} | ||
postSubscriberAttributes(newData: newData, | ||
network: network, | ||
appUserID: currentAppUserID, | ||
newDictToCache: newDictToCache) | ||
} | ||
} | ||
|
||
func postAppleSearchAdsAttributionIfNeeded() { | ||
guard attributionFetcher.isAuthorizedToPostSearchAds else { | ||
// should match OS availability in https://developer.apple.com/documentation/ad_services | ||
@available(iOS 14.3, macOS 11.1, macCatalyst 14.3, *) | ||
func postAdServicesTokenIfNeeded() { | ||
let latestTokenSent = latestNetworkIdAndAdvertisingIdentifierSent(network: .adServices) | ||
guard latestTokenSent == nil else { | ||
return | ||
} | ||
|
||
let latestIdsSent = latestNetworkIdAndAdvertisingIdentifierSent(network: .appleSearchAds) | ||
guard latestIdsSent == nil else { | ||
guard let attributionToken = attributionFetcher.adServicesToken else { | ||
return | ||
} | ||
|
||
attributionFetcher.afficheClientAttributionDetails { attributionDetails, error in | ||
guard let attributionDetails = attributionDetails, | ||
error == nil else { | ||
return | ||
} | ||
|
||
let attributionDetailsValues = Array(attributionDetails.values) | ||
let firstAttributionDict = attributionDetailsValues.first as? [String: NSObject] | ||
|
||
guard let hasIad = firstAttributionDict?["iad-attribution"] as? NSNumber, | ||
hasIad.boolValue == true else { | ||
return | ||
} | ||
|
||
self.post(attributionData: attributionDetails, fromNetwork: .appleSearchAds, networkUserId: nil) | ||
} | ||
Logger.debug("Logging attribution token for now to avoid lint warning: \(attributionToken)") | ||
// post | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe leave this as a |
||
} | ||
|
||
func postPostponedAttributionDataIfNeeded() { | ||
|
@@ -162,19 +142,6 @@ class AttributionPoster { | |
return cachedDict[networkID] | ||
} | ||
|
||
private func postSearchAds(newData: [String: Any], | ||
network: AttributionNetwork, | ||
appUserID: String, | ||
newDictToCache: [String: String]) { | ||
backend.post(attributionData: newData, network: network, appUserID: appUserID) { error in | ||
guard error == nil else { | ||
return | ||
} | ||
|
||
self.deviceCache.set(latestNetworkAndAdvertisingIdsSent: newDictToCache, appUserID: appUserID) | ||
} | ||
} | ||
|
||
private func postSubscriberAttributes(newData: [String: Any], | ||
network: AttributionNetwork, | ||
appUserID: String, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice