Skip to content
Draft
Show file tree
Hide file tree
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: 6 additions & 2 deletions OptimoveCore/Tests/Resources/notification-buttons.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion OptimoveCore/Tests/Sources/PushNotificationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public enum OptimoveNotificationService {
let bestAttemptContent = try await didReceive(request)
contentHandler(bestAttemptContent)
} catch {
assertionFailure(error.localizedDescription)
contentHandler(request.content)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions OptimoveSDK/Sources/Classes/Storage/FileStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Foundation
import OptimoveCore

protocol FileStorage {
public protocol FileStorage {
/// Check file if exist.
///
/// - Parameters:
Expand Down Expand Up @@ -87,7 +87,7 @@ extension FileStorage {
}
}

final class FileStorageImpl {
public final class FileStorageImpl {
enum FileStorageError: Error {
case unableToCreateDirectory
case unableToSaveFile
Expand All @@ -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
Expand All @@ -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))
Expand All @@ -143,17 +143,17 @@ extension FileStorageImpl: FileStorage {
}
}

func load<T>(fileName: String, isTemporary: Bool) throws -> T where T: Decodable, T: Encodable {
public func load<T>(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<T: Encodable>(data: T, toFileName fileName: String, isTemporary: Bool) throws {
public func save<T: Encodable>(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)
Expand All @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions OptimoveSDK/Sources/Classes/Storage/OptimoveStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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) {
Expand All @@ -70,7 +70,7 @@ extension StorageFacade {
}
}

subscript<T>(key: StorageKey) -> () throws -> T {
internal subscript<T>(key: StorageKey) -> () throws -> T {
get {
{ try cast(self.getStorage(for: key).value(for: key)) }
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import Foundation
import OptimoveCore

extension UserDefaults {
public extension UserDefaults {
enum Constants {
static let suiteName: String = "com.optimove.sdk"
}
Expand Down