Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Sources/StableID/StableID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class StableID {

private static var _remoteStore = NSUbiquitousKeyValueStore.default
private static var _localStore = UserDefaults(suiteName: Constants.StableID_Key_DefaultsSuiteName)

private static var isGeneratingFirstID: Bool = false

public static func configure(id: String? = nil, idGenerator: IDGenerator = StandardGenerator()) {
guard isConfigured == false else {
Expand Down Expand Up @@ -56,11 +58,17 @@ public class StableID {
self.logger.log(type: .info, message: "Configuring with local ID: \(localID)")
} else {
self.logger.log(type: .info, message: "No available identifier. Generating new unique user identifier...")

isGeneratingFirstID = true
}
}
}

_stableID = StableID(_id: identifier, _idGenerator: idGenerator)

if (isGeneratingFirstID) {
self.shared.generateID()
}

self.logger.log(type: .info, message: "Configured StableID. Current user ID: \(identifier)")

Expand Down