Open your app’s Onboarding/OnboardingManager.swift
file. In class OnboardingManager
, just above the delegate
field, add the following private fields:
private var nssResource: SAPcpmsClientResourcesDownloadStep.ClientResourceInfo? = nil
private var nssResourceURL: URL? = nil
The first field will store the stylesheet as an instance of SAPcpmsClientResourcesDownloadStep.ClientResourceInfo
. The second field will hold the internal URL to the downloaded stylesheet.
Now, create two helper functions. One will retrieve the uploaded stylesheet, and the other will construct a URL based on the results of the first method:
private func getNssResource() -> SAPcpmsClientResourcesDownloadStep.ClientResourceInfo {
let path = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let nssResource = SAPcpmsClientResourcesDownloadStep.ClientResourceInfo(mandatory: true, canOverwrite: true, name: "CustomTheme", version: nil, folderURL: path)
return nssResource
}
private func getNssResourceURL(nssResource: SAPcpmsClientResourcesDownloadStep.ClientResourceInfo) -> URL {
let url = nssResource.folderURL!.appendingPathComponent("\(nssResource.name ?? "Theme").nss").standardizedFileURL
return url
}
And finally, you need to modify the variables onboardingSteps
and restoringSteps
by adding a step for the download of the stylesheet, and a step for applying the stylesheet.
In both onboardingSteps
and restoringSteps
variables, add the following variable assignments:
nssResource = getNssResource()
nssResourceURL = getNssResourceURL(nssResource: nssResource!)
These variables are now assigned with the results from the two helper methods you created.
Then, in onboardingSteps
, add the following step right after the settingsDownload
step:
SAPcpmsClientResourcesDownloadStep(clientResourceInfoList: [nssResource!]),
and add the following right after the applyDuringOnboard
step:
NUIStyleSheetApplyStep(fileURL: nssResourceURL!),
Similarly, in restoringSteps
, add the following step right after the settingsDownload
step (which may be commented out, depending if you’re using an online or offline enabled app):
SAPcpmsClientResourcesDownloadStep(clientResourceInfoList: [nssResource!]),
and add the following right after the applyDuringRestore
step:
NUIStyleSheetApplyStep(fileURL: nssResourceURL!)