Skip to content

Commit a3c62b1

Browse files
gunoooo박건우
andauthored
feat: add reset() and deprecate removeUserId() (#35)
Co-authored-by: 박건우 <gunwoo@baggeon-uui-MacBookPro.local>
1 parent fa4784b commit a3c62b1

5 files changed

Lines changed: 45 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.9.0] - 2026-02-19
8+
9+
### Added
10+
11+
- `reset()` method to clear all local SDK state including device ID
12+
13+
### Deprecated
14+
15+
- `removeUserId()` — use `reset()` instead
16+
717
## [1.8.1] - 2026-02-13
818

919
### Added

Clix.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'Clix'
33
# Don't modify below line - it's automatically updated by scripts/update-version.sh
4-
spec.version = '1.8.1' # Don't modify this line - it's automatically updated by scripts/update-version.sh
4+
spec.version = '1.9.0' # Don't modify this line - it's automatically updated by scripts/update-version.sh
55
spec.summary = 'Clix iOS SDK for push notifications and analytics'
66
spec.description = <<-DESC
77
Clix iOS SDK provides push notification and analytics capabilities for iOS apps.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Clix iOS SDK is a powerful tool for managing push notifications and user events
88

99
```swift
1010
dependencies: [
11-
.package(url: "https://github.com/clix-so/clix-ios-sdk.git", from: "1.8.1")
11+
.package(url: "https://github.com/clix-so/clix-ios-sdk.git", from: "1.9.0")
1212
]
1313
```
1414

Sources/Core/Clix.swift

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -242,24 +242,15 @@ public final class Clix {
242242
}
243243
}
244244

245-
/// Removes the user ID (async version - recommended)
246-
///
247-
/// This async version ensures the operation completes before returning.
248-
/// Use this when you can await the operation in an async context.
249-
///
250-
/// - Throws: ClixError if the operation fails
245+
/// Removes the user ID (async version)
246+
@available(*, deprecated, message: "Use reset() instead")
251247
public static func removeUserId() async throws {
252248
await shared.initCoordinator.waitForInitialization()
253249
try await shared.get(\.deviceService).removeProjectUserId()
254250
}
255251

256252
/// Removes the user ID (synchronous version)
257-
///
258-
/// This synchronous version returns immediately while the operation continues in the background.
259-
/// Consider using the async version for guaranteed operation completion.
260-
///
261-
/// - Note: An async version is available that ensures the operation completes before returning.
262-
/// Use `try await Clix.removeUserId()` for better control over operation timing.
253+
@available(*, deprecated, message: "Use reset() instead")
263254
public static func removeUserId() {
264255
Task.detached(priority: .userInitiated) {
265256
do {
@@ -270,6 +261,31 @@ public final class Clix {
270261
}
271262
}
272263

264+
/// Resets all local SDK state including device ID.
265+
///
266+
/// After calling this method, you must call `initialize()` again before using the SDK.
267+
/// Use this when a user logs out and you want to start fresh with a new device identity.
268+
public static func reset() async throws {
269+
await shared.initCoordinator.waitForInitialization()
270+
let notificationService = try shared.get(\.notificationService)
271+
let storageService = try shared.get(\.storageService)
272+
await notificationService.reset()
273+
await storageService.remove("clix_device_id")
274+
await storageService.remove("clix_session_last_activity")
275+
await shared.initCoordinator.reset()
276+
}
277+
278+
/// Resets all local SDK state including device ID (synchronous version)
279+
public static func reset() {
280+
Task.detached(priority: .userInitiated) {
281+
do {
282+
try await reset()
283+
} catch {
284+
ClixLogger.error("Failed to reset: \(error)")
285+
}
286+
}
287+
}
288+
273289
/// Sets a user property (async version - recommended)
274290
///
275291
/// This async version ensures the operation completes before returning.
@@ -524,6 +540,10 @@ public final class Clix {
524540
}
525541
}
526542

543+
internal func reset() {
544+
isInitialized = false
545+
}
546+
527547
nonisolated internal func waitAndGet<T>(_ getter: @escaping () -> T?) -> T? {
528548
let semaphore = DispatchSemaphore(value: 0)
529549
var result: T?

Sources/Core/ClixVersion.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import Foundation
22

33
internal struct ClixVersion {
44
// Don't modify below line - it's automatically updated by scripts/update-version.sh
5-
internal static let current: String = "1.8.1"
5+
internal static let current: String = "1.9.0"
66
}

0 commit comments

Comments
 (0)