Repository navigation
Expand file tree
/
Copy pathSettings.swift
More file actions
811 lines (679 loc) · 26.9 KB
/
Copy pathSettings.swift
File metadata and controls
811 lines (679 loc) · 26.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
import AppTrackingTransparency
import Foundation
@objcMembers
@objc(FBSDKSettings)
public final class Settings: NSObject, SettingsProtocol, SettingsLogging, _ClientTokenProviding {
var configuredDependencies: ObjectDependencies?
var defaultDependencies: ObjectDependencies?
/// The shared settings instance. Prefer this and the exposed instance methods over the type properties and methods.
@objc(sharedSettings)
public static let shared = Settings()
/// The Facebook SDK version in use.
public var sdkVersion: String { FBSDK_VERSION_STRING }
/// The default Graph API version.
public var defaultGraphAPIVersion: String { FBSDK_DEFAULT_GRAPH_API_VERSION }
/**
The quality of JPEG images sent to Facebook from the SDK expressed as a value from 0.0 to 1.0.
The default value is 0.9.
*/
@objc(JPEGCompressionQuality)
public var jpegCompressionQuality: CGFloat {
get { _jpegCompressionQuality }
set {
validateConfiguration()
_jpegCompressionQuality = clampJPEGCompressionQuality(newValue)
logIfSDKSettingsChanged()
}
}
private static let defaultJPEGCompressionQuality: CGFloat = 0.9
private lazy var _jpegCompressionQuality = clampJPEGCompressionQuality(
self.infoDictionaryProvider?
.fb_object(forInfoDictionaryKey: PersistenceKey.jpegCompressionQuality.rawValue) as? CGFloat
?? Self.defaultJPEGCompressionQuality
)
private func clampJPEGCompressionQuality(_ quality: CGFloat) -> CGFloat {
quality.fb_clamped(to: 0.0 ... 1.0)
}
/**
Controls the automatic logging of basic app events such as `activateApp` and `deactivateApp`.
The default value is `true`.
*/
@available(
*,
deprecated,
message: """
This property is deprecated and will be removed in the next major release. \
Use `isAutoLogAppEventsEnabled` instead.
"""
)
public var autoLogAppEventsEnabled: Bool {
get { isAutoLogAppEventsEnabled }
set { isAutoLogAppEventsEnabled = newValue }
}
/**
Controls the automatic logging of basic app events such as `activateApp` and `deactivateApp`.
The default value is `true`. Automatic logging only happens when both this client-side value and
the corresponding server-side control are enabled; if either is disabled, automatic logging is off.
*/
public var isAutoLogAppEventsEnabled: Bool {
get { checkAutoLogAppEventsEnabled() }
set {
_isAutoLogAppEventsExplicitlySet = true
isAutoLogAppEventsEnabledLocally = newValue
}
}
/**
Controls the automatic logging of basic app events on the client side such as `activateApp` and `deactivateApp`.
The default value is `true`.
*/
internal var isAutoLogAppEventsEnabledLocally: Bool {
get { getPersistedBooleanProperty(.isAutoLogAppEventsEnabledLocally) }
set { setPersistedBooleanProperty(.isAutoLogAppEventsEnabledLocally, to: newValue) }
}
// swiftlint:disable:next identifier_name discouraged_optional_boolean
internal var _isAutoLogAppEventsEnabledLocally: Bool?
// swiftlint:disable:next identifier_name
internal var _isAutoLogAppEventsExplicitlySet = false
/**
Controls the `fb_codeless_debug` logging event.
The default value is `false`.
*/
@available(
*,
deprecated,
message: """
This property is deprecated and will be removed in the next major release. \
Use `isCodelessDebugLogEnabled` instead.
"""
)
public var codelessDebugLogEnabled: Bool {
get { isCodelessDebugLogEnabled }
set { isCodelessDebugLogEnabled = newValue }
}
/**
Controls the `fb_codeless_debug` logging event.
The default value is `false`.
*/
public var isCodelessDebugLogEnabled: Bool {
get { getPersistedBooleanProperty(.isCodelessDebugLogEnabled) }
set { setPersistedBooleanProperty(.isCodelessDebugLogEnabled, to: newValue) }
}
// swiftlint:disable:next identifier_name discouraged_optional_boolean
var _isCodelessDebugLogEnabled: Bool?
/**
Controls the access to IDFA.
The default value is `true`.
*/
@available(
*,
deprecated,
message: """
This property is deprecated and will be removed in the next major release. \
Use `isAdvertiserIDCollectionEnabled` instead.
"""
)
public var advertiserIDCollectionEnabled: Bool {
get { isAdvertiserIDCollectionEnabled }
set { isAdvertiserIDCollectionEnabled = newValue }
}
/**
Controls the access to IDFA.
The default value is `true`.
*/
public var isAdvertiserIDCollectionEnabled: Bool {
get { getPersistedBooleanProperty(.isAdvertiserIDCollectionEnabled) }
set { setPersistedBooleanProperty(.isAdvertiserIDCollectionEnabled, to: newValue) }
}
// swiftlint:disable:next identifier_name discouraged_optional_boolean
var _isAdvertiserIDCollectionEnabled: Bool?
/**
Controls metadata collection: the current screen title and the app link URLs.
The default value is `true`. An app disables collection by setting `FBSDKAutoLogMetaDataEnabled`
to `NO` in its Info.plist or by assigning `false` to this property at runtime. Collection also
requires the corresponding server-side control to be enabled.
*/
public var isMetaDataCollectionEnabled: Bool {
get { getPersistedBooleanProperty(.isMetaDataCollectionEnabled) }
set {
setPersistedBooleanProperty(.isMetaDataCollectionEnabled, to: newValue)
// The collectors are process-global and read `Settings.shared`, so only the shared
// instance drives them. Any other instance persists its value and stops there, rather
// than reaching across to state it does not own.
guard self === Self.shared else { return }
if newValue {
startMetaDataCollection()
} else {
stopMetaDataCollection()
}
}
}
/// Installs lazily so an app opting in mid-session gets collection without a relaunch.
private func startMetaDataCollection() {
// Checked first, so this stays inert and away from `ApplicationDelegate.shared` before setup.
guard _FeatureManager.shared.isEnabled(.metadataCollection) else { return }
ApplicationDelegate.shared.installMetadataCollectionIfPermitted()
}
/// Drops what was already collected: the swizzles are permanent and the app link URLs persist.
private func stopMetaDataCollection() {
_ScreenTitleObserver.shared.setScreenTitle(nil)
_AppLinkURLCache.shared.clearCachedURLs()
}
// swiftlint:disable:next identifier_name discouraged_optional_boolean
var _isMetaDataCollectionEnabled: Bool?
/**
Controls the automatic sending of diagnostic data about the app and the content on screen for product improvement.
The default value is `true`. An app disables it by setting `FBSDKAutoLogProductImprovementEnabled`
to `NO` in its Info.plist or by assigning `false` to this property at runtime. The data is sent
only when both this setting and the corresponding server-side control are enabled.
*/
public var isAutoLogProductImprovementEnabled: Bool {
get { getPersistedBooleanProperty(.isAutoLogProductImprovementEnabled) }
set { setPersistedBooleanProperty(.isAutoLogProductImprovementEnabled, to: newValue) }
}
// swiftlint:disable:next identifier_name discouraged_optional_boolean
var _isAutoLogProductImprovementEnabled: Bool?
/**
Controls the SKAdNetwork report.
The default value is `true`.
*/
@available(
*,
deprecated,
message: """
This property is deprecated and will be removed in the next major release. \
Use `isSKAdNetworkReportEnabled` instead.
"""
)
public var skAdNetworkReportEnabled: Bool {
get { isSKAdNetworkReportEnabled }
set { isSKAdNetworkReportEnabled = newValue }
}
/**
Controls the SKAdNetwork report.
The default value is `true`.
*/
public var isSKAdNetworkReportEnabled: Bool {
get { _isSKAdNetworkReportEnabled }
set {
validateConfiguration()
_isSKAdNetworkReportEnabled = newValue
// swiftformat:disable:this redundantSelf
self.dataStore?.fb_setObject(newValue, forKey: PersistenceKey.isSKAdNetworkReportEnabled.rawValue)
logIfSDKSettingsChanged()
}
}
private lazy var _isSKAdNetworkReportEnabled: Bool = {
let key = PersistenceKey.isSKAdNetworkReportEnabled.rawValue
return self.dataStore?.fb_object(forKey: key) as? Bool
?? self.infoDictionaryProvider?.fb_object(forInfoDictionaryKey: key) as? Bool
?? true
}()
/**
Whether data such as that generated through `AppEvents` and sent to Facebook
should be restricted from being used for purposes other than analytics and conversions.
The default value is `false`. This value is stored on the device and persists across app launches.
*/
public var isEventDataUsageLimited: Bool {
get { _isEventDataUsageLimited }
set {
_isEventDataUsageLimited = newValue
// swiftformat:disable:this redundantSelf
self.dataStore?.fb_setObject(newValue, forKey: PersistenceKey.limitEventAndDataUsage.rawValue)
}
}
private lazy var _isEventDataUsageLimited = self.dataStore?
.fb_object(forKey: PersistenceKey.limitEventAndDataUsage.rawValue) as? Bool
?? false
/**
Whether in-memory cached values should be used for expensive metadata fields, such as
carrier and advertiser ID, that are fetched on many `applicationDidBecomeActive` notifications.
The default value is `false`. This value is stored on the device and persists across app launches.
*/
public var shouldUseCachedValuesForExpensiveMetadata: Bool {
get { _shouldUseCachedValuesForExpensiveMetadata }
set {
_shouldUseCachedValuesForExpensiveMetadata = newValue
self.dataStore?.fb_setObject(newValue, forKey: PersistenceKey.useCachedValuesForExpensiveMetadata.rawValue)
}
}
private lazy var _shouldUseCachedValuesForExpensiveMetadata = self.dataStore?
.fb_object(forKey: PersistenceKey.useCachedValuesForExpensiveMetadata.rawValue) as? Bool
?? false
/// Controls error recovery for all `GraphRequest` instances created after the value is changed.
public var isGraphErrorRecoveryEnabled = true
/**
The Facebook App ID used by the SDK.
The default value will be read from the application's plist (FacebookAppID).
*/
public var appID: String? {
get { _appID }
set {
validateConfiguration()
_appID = newValue
logIfSDKSettingsChanged()
// Flush any requests that were queued before the SDK was configured to make them.
GraphRequestQueue.sharedInstance().flush()
}
}
private lazy var _appID = self.infoDictionaryProvider?
.fb_object(forInfoDictionaryKey: PersistenceKey.appID.rawValue) as? String
/**
The default URL scheme suffix used for sessions.
The default value will be read from the application's plist (FacebookUrlSchemeSuffix).
*/
public var appURLSchemeSuffix: String? {
get { getPersistedStringProperty(.appURLSchemeSuffix) }
set { setPersistedStringProperty(.appURLSchemeSuffix, to: newValue) }
}
// swiftlint:disable:next identifier_name
var _appURLSchemeSuffix: String?
/**
The client token needed for certain anonymous API calls (i.e., those made without a user-based access token).
An app's client token can be found by navigating to https://developers.facebook.com/apps/YOUR-APP-ID
(replacing "YOUR-APP-ID" with your actual app ID), choosing "Settings->Advanced" and scrolling to the "Security".
The default value will be read from the application's plist (FacebookClientToken).
*/
public var clientToken: String? {
get { getPersistedStringProperty(.clientToken) }
set {
setPersistedStringProperty(.clientToken, to: newValue)
// Flush any requests that were queued before the SDK was configured to make them.
GraphRequestQueue.sharedInstance().flush()
}
}
// swiftlint:disable:next identifier_name
var _clientToken: String?
/**
The Facebook Display Name used by the SDK.
This should match the Display Name that has been set for the app with the corresponding Facebook App ID
in the Facebook App Dashboard.
The default value will be read from the application's plist (FacebookDisplayName).
*/
public var displayName: String? {
get { getPersistedStringProperty(.displayName) }
set { setPersistedStringProperty(.displayName, to: newValue) }
}
// swiftlint:disable:next identifier_name
var _displayName: String?
/**
The Facebook domain part. This can be used to change the Facebook domain
(e.g. "beta") so that requests will be sent to `graph.beta.facebook.com`.
The default value will be read from the application's plist (FacebookDomainPart).
*/
public var facebookDomainPart: String? {
get { getPersistedStringProperty(.facebookDomainPart) }
set { setPersistedStringProperty(.facebookDomainPart, to: newValue) }
}
// swiftlint:disable:next identifier_name
var _facebookDomainPart: String?
/**
Overrides the default Graph API version to use with `GraphRequest` instances.
The string should be of the form `"v2.7"`.
The default value is `defaultGraphAPIVersion`.
*/
public lazy var graphAPIVersion = defaultGraphAPIVersion
/**
Internal property exposed to facilitate transition to Swift.
API Subject to change or removal without warning. Do not use.
@warning INTERNAL - DO NOT USE
*/
public var userAgentSuffix: String?
/**
Controls the advertiser tracking status of the data sent to Facebook.
*/
@available(
*,
deprecated,
message: """
This property is deprecated and will be removed in the next major release. \
Use `isAdvertiserTrackingEnabled` instead.
"""
)
public var advertiserTrackingEnabled: Bool {
get { isAdvertiserTrackingEnabled }
set { isAdvertiserTrackingEnabled = newValue }
}
/**
Controls the advertiser tracking status of the data sent to Facebook.
*/
public var isAdvertiserTrackingEnabled: Bool {
get { advertisingTrackingStatus == .allowed }
@available(
iOS,
deprecated: 17.0,
message: """
The setAdvertiserTrackingEnabled flag is not used for FBSDK v17+ on iOS 17+ \
as the FBSDK v17+ now relies on ATTrackingManager.trackingAuthorizationStatus.
"""
)
set(isNewlyAllowed) {
if _DomainHandler.sharedInstance().isDomainHandlingEnabled() {
// swiftlint:disable:next line_length
print("<Warning>: isAdvertiserTrackingEnabled setter has been deprecated and the value will be read from ATT status.")
return
}
advertisingTrackingStatus = isNewlyAllowed ? .allowed : .disallowed
recordSetAdvertiserTrackingEnabled()
}
}
/**
Internal property exposed to facilitate transition to Swift.
API Subject to change or removal without warning. Do not use.
@warning INTERNAL - DO NOT USE
*/
public var advertisingTrackingStatus: AdvertisingTrackingStatus {
get {
if _DomainHandler.sharedInstance().isDomainHandlingEnabled() {
return _advertisingTrackingStatusFromATT
} else {
return _advertisingTrackingStatus
}
}
set {
if _DomainHandler.sharedInstance().isDomainHandlingEnabled() {
// swiftlint:disable:next line_length
print("<Warning>: advertisingTrackingStatus setter has been deprecated and the value will be read from ATT status.")
return
}
_advertisingTrackingStatus = newValue
self.dataStore?.fb_setObject(newValue.rawValue, forKey: PersistenceKey.advertisingTrackingStatus.rawValue)
}
}
private var _advertisingTrackingStatusFromATT: AdvertisingTrackingStatus {
#if targetEnvironment(macCatalyst)
// ATTrackingManager is unavailable on Mac Catalyst and always
// returns .notDetermined. Treat Catalyst as tracking-allowed
// since ATT does not apply on macOS.
return .allowed
#else
let status: ATTrackingManager.AuthorizationStatus = ATTrackingManager.trackingAuthorizationStatus
switch status {
case .authorized:
return .allowed
case .denied, .restricted:
return .disallowed
case .notDetermined:
return .unspecified
@unknown default:
return .unspecified
}
#endif
}
private lazy var _advertisingTrackingStatus: AdvertisingTrackingStatus = {
guard let dependencies = try? getDependencies() else { return .unspecified }
if let persisted = dependencies.dataStore
.fb_object(forKey: PersistenceKey.advertisingTrackingStatus.rawValue) as? NSNumber {
return AdvertisingTrackingStatus(rawValue: persisted.uintValue) ?? .unspecified
} else {
return dependencies.appEventsConfigurationProvider.cachedAppEventsConfiguration.defaultATEStatus
}
}()
private static let isDataProcessingRestrictedOption = "ldu"
/**
Internal property exposed to facilitate transition to Swift.
API Subject to change or removal without warning. Do not use.
@warning INTERNAL - DO NOT USE
*/
public var isDataProcessingRestricted: Bool {
guard let options = persistableDataProcessingOptions?[DataProcessingOptionKey.options.rawValue] as? [String] else {
return false
}
return options.contains {
$0.caseInsensitiveCompare(Self.isDataProcessingRestrictedOption) == .orderedSame
}
}
/**
Internal property exposed to facilitate transition to Swift.
API Subject to change or removal without warning. Do not use.
@warning INTERNAL - DO NOT USE
*/
public private(set) lazy var persistableDataProcessingOptions: [DataProcessingOptionKey.RawValue: Any]? = {
guard let data = self.dataStore?.fb_object(forKey: PersistenceKey.dataProcessingOptions.rawValue) as? Data else {
return nil
}
let classes: [AnyClass] = [
NSString.self,
NSNumber.self,
NSArray.self,
NSDictionary.self,
NSSet.self,
]
return try? NSKeyedUnarchiver.unarchivedObject(ofClasses: classes, from: data)
as? [DataProcessingOptionKey.RawValue: Any]
}()
/**
Set the data processing options.
- Parameter options: The list of options.
*/
public func setDataProcessingOptions(_ options: [String]?) {
setDataProcessingOptions(options, country: 0, state: 0)
}
/**
Sets the data processing options.
- Parameters:
- options The list of the options.
- country The code for the country.
- state The code for the state.
*/
public func setDataProcessingOptions(_ options: [String]?, country: Int32, state: Int32) {
let values: [DataProcessingOptionKey.RawValue: Any] = [
DataProcessingOptionKey.options.rawValue: options ?? [],
DataProcessingOptionKey.country.rawValue: country,
DataProcessingOptionKey.state.rawValue: state,
]
persistableDataProcessingOptions = values
if let data = try? NSKeyedArchiver.archivedData(withRootObject: values, requiringSecureCoding: false) {
self.dataStore?.fb_setObject(data, forKey: PersistenceKey.dataProcessingOptions.rawValue)
}
}
/**
The current Facebook SDK logging behavior. This should consist of strings
defined as constants with `LoggingBehavior` that indicate what information should be logged.
Set to an empty set in order to disable all logging.
You can also define this via an array in your app's plist with the key "FacebookLoggingBehavior"; or add/remove
individual values via `enableLoggingBehavior(_:)` or `disableLoggingBehavior(_:)`
The default value is `[.developerErrors]`.
*/
public var loggingBehaviors: Set<LoggingBehavior> {
get { _loggingBehaviors }
set {
_loggingBehaviors = newValue
updateGraphAPIDebugBehavior()
}
}
private lazy var _loggingBehaviors: Set<LoggingBehavior> = {
if let persisted = self.infoDictionaryProvider?
.fb_object(forInfoDictionaryKey: PersistenceKey.loggingBehaviors.rawValue) as? [LoggingBehavior] {
return Set(persisted)
} else {
// Establish set of default enabled logging behaviors. You can completely disable logging by
// specifying an empty array for FacebookLoggingBehavior in your Info.plist.
return [.developerErrors]
}
}()
/**
Enable a particular Facebook SDK logging behavior.
- Parameter loggingBehavior: The logging behavior to enable. This should be a string constant defined
as a `LoggingBehavior`.
*/
public func enableLoggingBehavior(_ loggingBehavior: LoggingBehavior) {
loggingBehaviors.insert(loggingBehavior)
}
/**
Disable a particular Facebook SDK logging behavior.
- Parameter loggingBehavior: The logging behavior to disable. This should be a string constant defined
as a `LoggingBehavior`.
*/
public func disableLoggingBehavior(_ loggingBehavior: LoggingBehavior) {
loggingBehaviors.remove(loggingBehavior)
}
/// Check if a particular logging behavior is enabled.
/// Performs the membership check entirely in Swift to avoid the
/// ObjC NSSet bridge path that is vulnerable to linker ICF bugs
/// with static XCFrameworks.
public func isLoggingBehaviorEnabled(_ loggingBehavior: LoggingBehavior) -> Bool {
loggingBehaviors.contains(loggingBehavior)
}
/**
Internal property exposed to facilitate transition to Swift.
API Subject to change or removal without warning. Do not use.
@warning INTERNAL - DO NOT USE
*/
public var shouldUseTokenOptimizations: Bool {
get { _shouldUseTokenOptimizations }
set {
_shouldUseTokenOptimizations = newValue
self.dataStore?.fb_setObject(newValue, forKey: PersistenceKey.useTokenOptimizations.rawValue)
}
}
private lazy var _shouldUseTokenOptimizations = self.dataStore?
.fb_object(forKey: PersistenceKey.useTokenOptimizations.rawValue) as? Bool
?? true
/**
Internal property exposed to facilitate transition to Swift.
API Subject to change or removal without warning. Do not use.
@warning INTERNAL - DO NOT USE
*/
@available(
*,
deprecated,
message: """
This property is deprecated and will be removed in the next major release. \
Use `isATETimeSufficientlyDelayed` instead.
"""
)
public var isSetATETimeExceedsInstallTime: Bool { isATETimeSufficientlyDelayed }
/**
Internal property exposed to facilitate transition to Swift.
API Subject to change or removal without warning. Do not use.
@warning INTERNAL - DO NOT USE
*/
public var isATETimeSufficientlyDelayed: Bool {
guard
let installTimestamp = installTimestamp,
let ateTimestamp = advertiserTrackingEnabledTimestamp
else { return false }
let oneDayInSeconds: TimeInterval = 60.0 /* seconds */ * 60.0 /* minutes */ * 24.0 /* hours */
return ateTimestamp.timeIntervalSince(installTimestamp) > oneDayInSeconds
}
/**
Internal property exposed to facilitate transition to Swift.
API Subject to change or removal without warning. Do not use.
@warning INTERNAL - DO NOT USE
*/
public var installTimestamp: Date? {
self.dataStore?.fb_object(forKey: PersistenceKey.installTimestamp.rawValue) as? Date
}
/**
Internal property exposed to facilitate transition to Swift.
API Subject to change or removal without warning. Do not use.
@warning INTERNAL - DO NOT USE
*/
public var advertiserTrackingEnabledTimestamp: Date? {
self.dataStore?.fb_object(forKey: PersistenceKey.setAdvertiserTrackingEnabledTimestamp.rawValue) as? Date
}
private func updateGraphAPIDebugBehavior() {
// Enable warnings every time info is enabled
if loggingBehaviors.contains(.graphAPIDebugInfo), !loggingBehaviors.contains(.graphAPIDebugWarning) {
loggingBehaviors.insert(.graphAPIDebugWarning)
}
}
private enum GraphAPIDebugParameterValue: String {
case info
case warning
}
/**
Internal property exposed to facilitate transition to Swift.
API Subject to change or removal without warning. Do not use.
@warning INTERNAL - DO NOT USE
*/
@available(
*,
deprecated,
message: """
This property is deprecated and will be removed in the next major release. \
Use `graphAPIDebugParameterValue` instead.
"""
)
public var graphAPIDebugParamValue: String? { graphAPIDebugParameterValue }
/**
Internal property exposed to facilitate transition to Swift.
API Subject to change or removal without warning. Do not use.
@warning INTERNAL - DO NOT USE
*/
public var graphAPIDebugParameterValue: String? {
if loggingBehaviors.contains(.graphAPIDebugInfo) {
return GraphAPIDebugParameterValue.info.rawValue
} else if loggingBehaviors.contains(.graphAPIDebugWarning) {
return GraphAPIDebugParameterValue.warning.rawValue
} else {
return nil
}
}
/// The minimum interval between automatic Limited Login background refreshes, in seconds.
///
/// Auto-refresh runs once per foreground for any active Limited Login session whose
/// token carries a `cnf.jkt` binding (Phase 3 DPoP). Tokens without the binding fall
/// through as a no-op. The interval throttles repeated foregrounds within the window.
///
/// The default value is `86400.0` (24 hours).
public var limitedLoginAutoRefreshInterval: TimeInterval = 86_400.0
/// Controls whether to show domain errors.
public var isDomainErrorEnabled = true
/**
Controls whether to add the user to the messaging customer base for WhatsApp.
The default value is `nil` (field not sent in the payload).
Set to `true` or `false` to explicitly include the field in the payload.
This value is stored on the device and persists across app launches.
*/
public var addToMessagingCustomerBaseForWhatsApp: NSNumber? {
get {
self.dataStore?.fb_object(
forKey: PersistenceKey.addToMessagingCustomerBaseForWhatsApp.rawValue
) as? NSNumber
}
set {
if let newValue {
self.dataStore?.fb_setObject(newValue, forKey: PersistenceKey.addToMessagingCustomerBaseForWhatsApp.rawValue)
} else {
self.dataStore?.fb_removeObject(forKey: PersistenceKey.addToMessagingCustomerBaseForWhatsApp.rawValue)
}
}
}
#if DEBUG
func reset() {
_loggingBehaviors = [.developerErrors]
resetDependencies()
}
#endif
}
// MARK: - Dependencies
extension Settings: DependentAsObject {
struct ObjectDependencies {
var appEventsConfigurationProvider: _AppEventsConfigurationProviding
var serverConfigurationProvider: _ServerConfigurationProviding
var dataStore: DataPersisting
var eventLogger: EventLogging
var infoDictionaryProvider: InfoDictionaryProviding
}
func validateConfiguration() {
#if DEBUG
// swiftlint:disable:next statement_position
do { _ = try getDependencies() }
catch { fatalError(Self.unconfiguredDebugMessage) }
#endif
}
static let unconfiguredDebugMessage = """
As of v9.0, you must initialize the SDK prior to calling any methods or setting any properties. \
You can do this by calling `ApplicationDelegate.application(_:didFinishLaunchingWithOptions:)`. \
Learn more: https://developers.facebook.com/docs/ios/getting-started. \
If no `UIApplication` instance is available, you can use `ApplicationDelegate.initializeSDK()`.
"""
}