From cf7f4ba62760f9cae834f087ae1f9a9e4ca626ab Mon Sep 17 00:00:00 2001 From: Eli Gutovsky Date: Tue, 12 Dec 2023 02:39:49 +0200 Subject: [PATCH 1/5] fix: access for qa --- .../Classes/Storage/FileManager+Optimove.swift | 2 +- .../Sources/Classes/Storage/FileStorage.swift | 18 +++++++++--------- .../Classes/Storage/OptimoveStorage.swift | 14 +++++++------- .../Storage/UserDefaults+Optimove.swift | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/OptimoveSDK/Sources/Classes/Storage/FileManager+Optimove.swift b/OptimoveSDK/Sources/Classes/Storage/FileManager+Optimove.swift index d286f3d8..c0f6c3c2 100644 --- a/OptimoveSDK/Sources/Classes/Storage/FileManager+Optimove.swift +++ b/OptimoveSDK/Sources/Classes/Storage/FileManager+Optimove.swift @@ -4,7 +4,7 @@ import Foundation private var temporaryDirectoryURL: URL? -extension FileManager { +public extension FileManager { static func optimoveURL() throws -> URL { return try FileManager.default.url( for: .applicationSupportDirectory, diff --git a/OptimoveSDK/Sources/Classes/Storage/FileStorage.swift b/OptimoveSDK/Sources/Classes/Storage/FileStorage.swift index 8842d701..7bcb2294 100644 --- a/OptimoveSDK/Sources/Classes/Storage/FileStorage.swift +++ b/OptimoveSDK/Sources/Classes/Storage/FileStorage.swift @@ -3,7 +3,7 @@ import Foundation import OptimoveCore -protocol FileStorage { +public protocol FileStorage { /// Check file if exist. /// /// - Parameters: @@ -87,7 +87,7 @@ extension FileStorage { } } -final class FileStorageImpl { +public final class FileStorageImpl { enum FileStorageError: Error { case unableToCreateDirectory case unableToSaveFile @@ -103,7 +103,7 @@ final class FileStorageImpl { let persistentStorageURL: URL let temporaryStorageURL: URL - init(persistentStorageURL: URL, temporaryStorageURL: URL) throws { + public init(persistentStorageURL: URL, temporaryStorageURL: URL) throws { fileManager = FileManager.default self.persistentStorageURL = persistentStorageURL self.temporaryStorageURL = temporaryStorageURL @@ -125,13 +125,13 @@ final class FileStorageImpl { } extension FileStorageImpl: FileStorage { - func isExist(fileName: String, isTemporary: Bool) -> Bool { + public func isExist(fileName: String, isTemporary: Bool) -> Bool { let url = getDirectory(isTemporary: isTemporary) let fileUrl = url.appendingPathComponent(fileName) return fileManager.fileExists(atPath: fileUrl.path) } - func loadData(fileName: String, isTemporary: Bool) throws -> Data { + public func loadData(fileName: String, isTemporary: Bool) throws -> Data { let fileUrl = getDirectory(isTemporary: isTemporary).appendingPathComponent(fileName) do { let contents = try unwrap(fileManager.contents(atPath: fileUrl.path)) @@ -143,17 +143,17 @@ extension FileStorageImpl: FileStorage { } } - func load(fileName: String, isTemporary: Bool) throws -> T where T: Decodable, T: Encodable { + public func load(fileName: String, isTemporary: Bool) throws -> T where T: Decodable, T: Encodable { let data = try loadData(fileName: fileName, isTemporary: isTemporary) return try JSONDecoder().decode(T.self, from: data) } - func save(data: T, toFileName fileName: String, isTemporary: Bool) throws { + public func save(data: T, toFileName fileName: String, isTemporary: Bool) throws { let data = try JSONEncoder().encode(data) try saveData(data: data, toFileName: fileName, isTemporary: isTemporary) } - func saveData(data: Data, toFileName fileName: String, isTemporary: Bool) throws { + public func saveData(data: Data, toFileName fileName: String, isTemporary: Bool) throws { do { let url = getDirectory(isTemporary: isTemporary) try fileManager.createDirectory(at: url, withIntermediateDirectories: true) @@ -169,7 +169,7 @@ extension FileStorageImpl: FileStorage { } } - func delete(fileName: String, isTemporary: Bool) throws { + public func delete(fileName: String, isTemporary: Bool) throws { do { let fileUrl = getDirectory(isTemporary: isTemporary).appendingPathComponent(fileName) try fileManager.removeItem(at: fileUrl) diff --git a/OptimoveSDK/Sources/Classes/Storage/OptimoveStorage.swift b/OptimoveSDK/Sources/Classes/Storage/OptimoveStorage.swift index 72479c1b..544f19b2 100644 --- a/OptimoveSDK/Sources/Classes/Storage/OptimoveStorage.swift +++ b/OptimoveSDK/Sources/Classes/Storage/OptimoveStorage.swift @@ -4,7 +4,7 @@ import Foundation import OptimoveCore /// Combined protocol for a convenince access to stored values and files. -typealias OptimoveStorage = FileStorage & KeyValueStorage & StorageValue +public typealias OptimoveStorage = FileStorage & KeyValueStorage & StorageValue enum StorageError: LocalizedError { case noValue(StorageKey) @@ -18,14 +18,14 @@ enum StorageError: LocalizedError { } /// Class implements the Façade pattern for hiding complexity of the OptimoveStorage protocol. -final class StorageFacade: OptimoveStorage { +public final class StorageFacade: OptimoveStorage { // FIXME: - Split persistance storage to AppGroup and Standart private let standardStorage: KeyValueStorage private let appGroupStorage: KeyValueStorage private let inMemoryStorage: KeyValueStorage private let fileStorage: FileStorage - init( + public init( standardStorage: KeyValueStorage, appGroupStorage: KeyValueStorage, inMemoryStorage: KeyValueStorage, @@ -50,7 +50,7 @@ final class StorageFacade: OptimoveStorage { // MARK: - KeyValueStorage -extension StorageFacade { +public extension StorageFacade { /// Use `storage.key` instead. /// Some variable have formatters, implemented in own setters. Set unformatted value could cause an issue. func set(value: Any?, key: StorageKey) { @@ -70,7 +70,7 @@ extension StorageFacade { } } - subscript(key: StorageKey) -> () throws -> T { + internal subscript(key: StorageKey) -> () throws -> T { get { { try cast(self.getStorage(for: key).value(for: key)) } } @@ -82,7 +82,7 @@ extension StorageFacade { // MARK: - FileStorage -extension StorageFacade { +public extension StorageFacade { func isExist(fileName: String, isTemporary: Bool) -> Bool { return fileStorage.isExist(fileName: fileName, isTemporary: isTemporary) } @@ -110,7 +110,7 @@ extension StorageFacade { // MARK: - StorageValue -extension KeyValueStorage where Self: StorageValue { +public extension KeyValueStorage where Self: StorageValue { var installationID: String? { get { return self[.installationID] diff --git a/OptimoveSDK/Sources/Classes/Storage/UserDefaults+Optimove.swift b/OptimoveSDK/Sources/Classes/Storage/UserDefaults+Optimove.swift index 43e30cf9..42f28bee 100644 --- a/OptimoveSDK/Sources/Classes/Storage/UserDefaults+Optimove.swift +++ b/OptimoveSDK/Sources/Classes/Storage/UserDefaults+Optimove.swift @@ -3,7 +3,7 @@ import Foundation import OptimoveCore -extension UserDefaults { +public extension UserDefaults { enum Constants { static let suiteName: String = "com.optimove.sdk" } From 7f11ff0020123e908279cc7c76fd53c743969913 Mon Sep 17 00:00:00 2001 From: Eli Gutovsky Date: Tue, 12 Dec 2023 12:48:05 +0200 Subject: [PATCH 2/5] chore: update buttons --- OptimoveCore/Tests/Resources/notification-buttons.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OptimoveCore/Tests/Resources/notification-buttons.json b/OptimoveCore/Tests/Resources/notification-buttons.json index 0abe1aab..e5474964 100644 --- a/OptimoveCore/Tests/Resources/notification-buttons.json +++ b/OptimoveCore/Tests/Resources/notification-buttons.json @@ -17,14 +17,18 @@ "k.buttons": [ { "id": "1", - "text": "action_1" + "text": "action_1", + "icon": { + "type": "system", + "id": "figure.walk" + } }, { "id": "2", "text": "action_2", "icon": { "type": "system", - "id": "sys_icon_id" + "id": "sun.max.fill" } }, { From 2d0e83762974e479283ac247a8f9116f4970603c Mon Sep 17 00:00:00 2001 From: Eli Gutovsky Date: Tue, 12 Dec 2023 12:48:22 +0200 Subject: [PATCH 3/5] fix: url --- OptimoveSDK/Sources/Classes/Optimobile/AnalyticsHelper.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OptimoveSDK/Sources/Classes/Optimobile/AnalyticsHelper.swift b/OptimoveSDK/Sources/Classes/Optimobile/AnalyticsHelper.swift index b548ee3f..61cb364e 100644 --- a/OptimoveSDK/Sources/Classes/Optimobile/AnalyticsHelper.swift +++ b/OptimoveSDK/Sources/Classes/Optimobile/AnalyticsHelper.swift @@ -228,7 +228,7 @@ final class AnalyticsHelper { eventIds.append(event.objectID) } - let path = "/v1/app-installs/\(OptimobileHelper.installId)/events" + let path = "/v1/app-installs/\(optimobileHelper.installId())/events" eventsHttpClient.sendRequest(.POST, toPath: path, data: data, onSuccess: { _, _ in if let err = self.pruneEventsBatch(context, eventIds) { From 2118e7dc0cf1cb518887d8e34c23d5b92b9a7f28 Mon Sep 17 00:00:00 2001 From: Eli Gutovsky Date: Tue, 12 Dec 2023 14:38:12 +0200 Subject: [PATCH 4/5] chore: do not assert other notifications --- .../Sources/OptimoveNotificationService.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/OptimoveNotificationServiceExtension/Sources/OptimoveNotificationService.swift b/OptimoveNotificationServiceExtension/Sources/OptimoveNotificationService.swift index 6c775a02..9095e464 100644 --- a/OptimoveNotificationServiceExtension/Sources/OptimoveNotificationService.swift +++ b/OptimoveNotificationServiceExtension/Sources/OptimoveNotificationService.swift @@ -20,7 +20,6 @@ public enum OptimoveNotificationService { let bestAttemptContent = try await didReceive(request) contentHandler(bestAttemptContent) } catch { - assertionFailure(error.localizedDescription) contentHandler(request.content) } } From dfc2b52bec58d27dbfe14b701bca26fe94dccc67 Mon Sep 17 00:00:00 2001 From: Eli Gutovsky Date: Thu, 14 Dec 2023 17:20:57 +0200 Subject: [PATCH 5/5] fix: test --- OptimoveCore/Tests/Sources/PushNotificationTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OptimoveCore/Tests/Sources/PushNotificationTests.swift b/OptimoveCore/Tests/Sources/PushNotificationTests.swift index fbea0fa0..3c42da53 100644 --- a/OptimoveCore/Tests/Sources/PushNotificationTests.swift +++ b/OptimoveCore/Tests/Sources/PushNotificationTests.swift @@ -32,7 +32,7 @@ final class PushNotificationTests: XCTestCase, FileAccessible { XCTAssertEqual(notification.buttons?[1].id, "2") XCTAssertEqual(notification.buttons?[1].text, "action_2") - XCTAssertEqual(notification.buttons?[1].icon?.id, "sys_icon_id") + XCTAssertEqual(notification.buttons?[1].icon?.id, "sun.max.fill") XCTAssertEqual(notification.buttons?[1].icon?.type, .system) XCTAssertEqual(notification.buttons?[2].id, "3")