Saving and Loading Projects
As soon as you initialize the Mobile SDK’s editor with a ProductConfiguration
, you have basically started a new photo product design process resulting in the creation of a so-called Project
, which you can save and load at any time to persist progress and continue the editing process later.
Saving Projects
Users have the possibility to save their projects in the editor to continue creation at a later point in time. This stored version is called a Project
and contains information e.g. about the product and its selected options or the title the user has chosen for the project:
public struct Project: Codable {
public let location: ProjectStorageLocation
public let id: Int
public let title: String
public let productId: Int
public let appliedProductOptions: [String:String]
public let lastModifiedDate: Date
public let sizeInBytes: Int
public let expirationDate: Date
public var previewImage: UIImage? = nil
}
Saving projects is triggered and handled in the editor itself, so there are no additional steps you need to take for this functionality.
Listing Projects
Projects can be stored either on the user’s device or in the cloud (infrastructure hosted by ip.labs), which also enables editing of the project on other platforms (e.g. in the web).
Listing local projects can be done via retrieveLocalProjects
.
let result = await IplabsMobileSdk.shared.retrieveLocalProjects()
switch result {
case .success(let projectList):
// display list of user’s projects
case .failure(let error):
// communicate error to the user
}
To get a list of cloud projects, you need to call the retrieveCloudProjects
method with a valid WipeSSO session ID for an authenticated user. We provide overloads with a completionHandler
or async
/ await
.
let result = await IplabsMobileSdk.shared.retrieveCloudProjects(sessionId: sessionId)
switch result {
case .success(let projectList):
// display list of user’s projects
case .failure(let error):
// communicate error to the user
}
If a call of either retrieveLocalProjects
or retrieveCloudProjects
was successful, you get a list of Project
instances. You can now use this information to display the user’s locally / remotely saved projects in your UI.
Loading a Project
Loading a previously stored project is achieved by initializing a new editor with this Project
instance instead of a ProductConfiguration
. See the Quickstart Guide on how to include an EditorView
in your app and use this variant of the initialization call instead of the one described there:
let editorViewController = IplabsMobileSdk.shared.initializeEditor(
project: yourProject,
sessionId: yourSessionId
)
Renaming a Project
You can give your users the opportunity to change the title of their saved projects. To achieve this, use the renameLocalProject
or renameCloudProject
methods respectively, depending on the saved project’s location. You have to provide the orginal project and its new title and for cloud projects a valid session ID for the owner as well:
let localProjectRenamingResult = await renameLocalProject(
project: project,
newTitle: newTitle
)
let cloudProjectRenamingResult = await renameCloudProject(
project: project,
newTitle: newTitle,
sessionId: yourSessionId
)
Removing a Project
Finally, you can also remove saved projects in case your users no longer need them. For that please use the removeLocalProject
and removeCloudProject
methods respetively, depending on the saved project’s location. They require the original project and again a valid session ID for the owner as arguments:
let localProjectRemovalResult = await deleteLocalProject(
project: yourLocalProject
)
let cloudProjectRemovalResult = await deleteCloudProject(
project: yourCloudProject,
sessionId: yourSessionId
)