Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Source/Database/ObjectManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import RealmSwift

public class ObjectManager<T: Object> {
let realm = try! Realm()
let realm = try! Realm(configuration: TPStreamsSDK.realmConfig)

func add(object: T) {
try! realm.write {
Expand Down
19 changes: 13 additions & 6 deletions Source/TPStreamsSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import RealmSwift


public class TPStreamsSDK {
internal static let realmConfig: Realm.Configuration = buildRealmConfig()
internal static var orgCode: String?
internal static var provider: Provider = .tpstreams
internal static var authToken: String?
Expand Down Expand Up @@ -86,20 +87,26 @@ public class TPStreamsSDK {
}
}

private static func initializeDatabase() {
private static func buildRealmConfig() -> Realm.Configuration {
var config = Realm.Configuration(
schemaVersion: 5,
migrationBlock: { migration, oldSchemaVersion in
if oldSchemaVersion < 5 {
// No manual migration needed.
// Realm automatically handles newly added optional properties.
}
}
},
objectTypes: [LocalOfflineAsset.self]
)
config.fileURL!.deleteLastPathComponent()
config.fileURL!.appendPathComponent("TPStreamsPlayerSDK")
config.fileURL!.appendPathExtension("realm")
Realm.Configuration.defaultConfiguration = config
config.fileURL = config.fileURL?
.deletingLastPathComponent()
.appendingPathComponent("TPStreamsPlayerSDK")
.appendingPathExtension("realm")
return config
}

private static func initializeDatabase() {
_ = Self.realmConfig
}

private static func removeIncompleteDownloads() {
Expand Down
Loading