-
Notifications
You must be signed in to change notification settings - Fork 5
Resolver Specific Parameters (ID5 Mobile In-App) #58
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
base: master
Are you sure you want to change the base?
Changes from all commits
b72ebc8
1abc018
7e45db9
7d87934
3a34d55
e6a6164
5169573
16a6357
855a69b
5cf1b4e
d837949
be82f77
87c4587
2bd295a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // | ||
| // Bundle++.swift | ||
| // OptableSDK | ||
| // | ||
| // Copyright © 2026 Optable Technologies, Inc. All rights reserved. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| extension Bundle { | ||
| /// The app's release version (`CFBundleShortVersionString`), if present. | ||
| var appVersionString: String? { | ||
| infoDictionary?["CFBundleShortVersionString"] as? String | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,18 +116,31 @@ public extension OptableSDK { | |
| // MARK: - Targeting | ||
| public extension OptableSDK { | ||
| /** | ||
| targeting(ids?, completion) calls the Optable Sandbox Targeting API and returns key-value targeting data | ||
| for the current user/device/app. You may optionally supply identifiers to enrich the request. | ||
|
|
||
| On completion, the handler receives: | ||
| - .success(OptableTargeting) on success | ||
| - .failure(Error) on failure | ||
| targeting(ids?, hids?, completion) calls the Optable Sandbox Targeting API and returns key-value targeting data | ||
|
OlenaPostindustria marked this conversation as resolved.
|
||
| for the current user/device/app. | ||
|
|
||
| - Parameters: | ||
| - ids: one or more identifiers to resolve, sent as repeated `id` query parameters. The DCN evaluates them | ||
| in the order they are listed and returns the profile of the first successful match (querying the | ||
| first-party graph before any third-party graphs). When provided, they take precedence over any | ||
| identifier in the passport. | ||
| - hids: hint identifiers, sent as `hid` query parameters in addition to `ids`. Hints drive resolver-specific | ||
| identity resolution on the DCN, such as ID5 Mobile In-App. Only the identifier types valid as hints are | ||
| forwarded: email address, phone number, IPv6 address, Apple IDFA, Google GAID and custom IDs — any other | ||
| type in `hids` is dropped client-side. Custom (`cN`) prefixes must be configured on the DCN; unconfigured | ||
| ones are ignored server-side. | ||
| - completion: on completion, the handler receives: | ||
| - .success(OptableTargeting) on success | ||
| - .failure(Error) on failure | ||
|
|
||
| Unless `skipAdvertisingIdDetection` is set in the config, the device IDFA is automatically prepended to both | ||
| lists when ad tracking is authorized. | ||
|
|
||
| On success, the result is cached in client storage. You can read it using targetingFromCache() | ||
| and clear it using targetingClearCache(). | ||
| */ | ||
| func targeting(_ ids: [OptableIdentifier]? = nil, completion: @escaping (Result<OptableTargeting, Error>) -> Void) throws { | ||
| try _targeting(ids: ids, completion: completion) | ||
| func targeting(_ ids: [OptableIdentifier]? = nil, hids: [OptableIdentifier]? = nil, completion: @escaping (Result<OptableTargeting, Error>) -> Void) throws { | ||
| try _targeting(ids: ids, hids: hids, completion: completion) | ||
| } | ||
|
|
||
| /// targetingFromCache() returns the previously cached targeting data, if any. | ||
|
|
@@ -144,15 +157,18 @@ public extension OptableSDK { | |
|
|
||
| // MARK: Async/Await support | ||
| /** | ||
| This is the Swift Concurrency compatible version of the `targeting(completion)` API. | ||
| This is the Swift Concurrency compatible version of the `targeting(ids, hids, completion)` API: | ||
| `ids` match the user/device against the DCN, while `hids` are hint identifiers driving resolver-specific | ||
| identity resolution such as ID5 Mobile In-App — see `targeting(_:hids:completion:)` for details on which | ||
| identifier types are valid hints. | ||
|
|
||
| Instead of completion callbacks, results are returned via async/await. | ||
| */ | ||
| @available(iOS 13.0, *) | ||
| func targeting(_ ids: [OptableIdentifier]? = nil) async throws -> OptableTargeting { | ||
| func targeting(_ ids: [OptableIdentifier]? = nil, hids: [OptableIdentifier]? = nil) async throws -> OptableTargeting { | ||
| return try await withCheckedThrowingContinuation({ [unowned self] continuation in | ||
| do { | ||
| try self._targeting(ids: ids, completion: { continuation.resume(with: $0) }) | ||
| try self._targeting(ids: ids, hids: hids, completion: { continuation.resume(with: $0) }) | ||
| } catch { | ||
| continuation.resume(throwing: error) | ||
| } | ||
|
|
@@ -311,12 +327,14 @@ extension OptableSDK { | |
| }).resume() | ||
| } | ||
|
|
||
| func _targeting(ids: [OptableIdentifier]?, completion: @escaping (Result<OptableTargeting, Error>) -> Void) throws { | ||
| func _targeting(ids: [OptableIdentifier]?, hids: [OptableIdentifier]?, completion: @escaping (Result<OptableTargeting, Error>) -> Void) throws { | ||
| var ids = ids ?? [] | ||
| var hids = hids ?? [] | ||
|
|
||
| enrichIfNeeded(ids: &ids) | ||
| enrichIfNeeded(ids: &hids) | ||
|
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. Major - all existing callers are silently opted into hint/ID5 resolution. If that implicit opt-in is intended edge behavior, fine - otherwise gate
Collaborator
Author
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.
|
||
|
|
||
| guard let request = try api.targeting(ids: ids) else { | ||
| guard let request = try api.targeting(ids: ids, hids: hids) else { | ||
| throw OptableError.targeting("Failed to create targeting request") | ||
| } | ||
|
|
||
|
|
@@ -340,6 +358,10 @@ extension OptableSDK { | |
|
|
||
| /// We cache the latest targeting result in client storage for targetingFromCache() users: | ||
| self.api.storage.setTargeting(optableTargeting) | ||
|
|
||
| if let id5Signature = optableTargeting.id5Signature { | ||
| self.api.storage.setID5Signature(id5Signature) | ||
| } | ||
|
|
||
| completion(.success(optableTargeting)) | ||
| } catch { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.