File tree 3 files changed +16
-4
lines changed
3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -830,13 +830,23 @@ public struct AIProxy {
830
830
}
831
831
#endif
832
832
833
+ /// This is a beta feature.
834
+ /// It returns a stable, anonymous identifier that you can annotate requests to AIProxy with.
835
+ /// You must add the 'iCloud key-value storage' capability to use this:
836
+ /// 1. Tap on your project in Xcode's project tree
837
+ /// 2. Tap on your target in the sidebar
838
+ /// 3. Tap on Signing & Capabilities in the top nav
839
+ /// 4. Tap the plus sign next to 'Capability'
840
+ /// 5. Add iCloud
841
+ /// 6. Select the 'Key-value storage' service
833
842
@NetworkActor
834
- public static func configure_BETA ( ) async {
843
+ public static func getStableIdentifier ( ) async -> String ? {
835
844
do {
836
- try await AnonymousAccountStorage . sync ( )
845
+ return try await AnonymousAccountStorage . sync ( )
837
846
} catch {
838
847
aiproxyLogger. critical ( " Could not configure an AIProxy anonymous account: \( error. localizedDescription) " )
839
848
}
849
+ return nil
840
850
}
841
851
842
852
private init ( ) {
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ private let kAIProxyRemoteAccount = "aiproxy-remote"
12
12
internal let kAIProxyUKVSAccount = " aiproxy-ukvs "
13
13
14
14
15
- public final class AIProxyStorage {
15
+ final class AIProxyStorage {
16
16
17
17
static private let keychain = AIProxyKeychain ( )
18
18
static private let ukvs = NSUbiquitousKeyValueStore . default
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ final class AnonymousAccountStorage {
38
38
private static var localAccountChain : [ AnonymousAccount ] = [ ]
39
39
40
40
/// This is expected to be called as part of the application launch.
41
- static func sync( ) async throws {
41
+ static func sync( ) async throws -> String {
42
42
#if false
43
43
try await AIProxyStorage . clear ( )
44
44
#endif
@@ -133,6 +133,8 @@ final class AnonymousAccountStorage {
133
133
aiproxyLogger. info ( " Local account chain is \( localAccountChain) " )
134
134
aiproxyLogger. info ( " Anonymous account identifier is \( self . resolvedAccount!. uuid) " )
135
135
#endif
136
+
137
+ return localAccount. uuid
136
138
}
137
139
138
140
/// Called when NSUbiquitousKeyValueStore was remotely updated.
You can’t perform that action at this time.
0 commit comments