PersonalDataFactory

public enum PersonalDataFactory

A factory to create PersonalData instances with an offline storage and/or online synchronization. See more information in PersonalData.

Important

This is a Public Preview API. It may be changed or removed at any time.
  • Defaults types and constants used for PersonalDataFactory

    See more

    Declaration

    Swift

    public enum Defaults
  • Creates a new instace of PersonalData implemented for an offline storage to store updates to a file.

    An example of creating an offline PersonalData instance:

    let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
    let documentsFolderPath = paths[0]
    let filePath = documentsFolderPath.appendingPathComponent("personal_data")
    do {
        let personalData = try PersonalDataFactory.create(with: filePath.absoluteString)
        print(personalData)
        // Use personalData to pass to other engines that require it for personalizations.
    } catch let error {
        print(error)
    }
    

    Throws

    PersonalDataFactoryError.cannotUseFilepath error if the file path could not be used for storage.

    Important

    This is a Public Preview API. It may be changed or removed at any time.

    Declaration

    Swift

    public static func create(with filePath: String) throws -> PersonalData

    Parameters

    filePath

    A file path to store provided personalized data. To ensure correcness ensure that the path has a proper access rights for reading/writing.

    Return Value

    An instance of the PersonalData with offline storage.

  • Creates a new instace of PersonalData implemented for an offline file storage. This method relies on TomTomSDKPersonalDataDefault/PersonalDataFactory/defaultFilePath path to store PersonalData data. To configure filePath use TomTomSDKPersonalDataDefault/PersonalDataFactory/create(with:).

    Throws

    PersonalDataFactoryError.cannotUseFilepath error if the default file path could not be used for storage.

    Important

    This is a Public Preview API. It may be changed or removed at any time.

    Declaration

    Swift

    public static func create() throws -> PersonalData

    Return Value

    An instance of the PersonalData with offline storage.