PersonalData

public protocol PersonalData

Implementations of PersonalData enable easy access to the personal data. Personal data refers to personal locations (home/work/favorites), recent destinations, personal preferences relevant to search, routing and guidance, and potentially other data needed to create navigation applications that are “connected” to the users digital life.

Important

This is a Public Preview API. It may be changed or removed at any time.
  • Loads the user profile asynchronously from persistent storage. The returned user profile is a snapshot of the current state of personal data. All modifications can be persisted by calling PersonalData.storeUserProfile. To get notified about data updates, subscribe for the updates by using the addUserProfileUpdateObserver method.

    Declaration

    Swift

    @discardableResult
    func loadUserProfile(completion: @escaping (Result<UserProfile, Error>) -> ()) -> Cancellable

    Parameters

    completion

    Completion handler that gets user profile.

    Return Value

    a Cancellable instance that provides control for request cancellation.

  • Loads the user profile from persistent storage synchronously. The loaded profile is a snapshot of the data at the moment of calling the method. To save the changes made in the snapshot back into the storage, use the PersonalData.storeUserProfile method. To get notified about data updates, subscribe for the updates by using the PersonalData.addUserProfileUpdateObserver method.

    Throws

    An error if loading the user profile fails.

    Declaration

    Swift

    func loadUserProfile() throws -> UserProfile

    Return Value

    An instance of UserProfile.

  • Stores the user profile with the changes provided asynchronously to persistent storage.

    Declaration

    Swift

    func storeUserProfile(_ userProfile: UserProfile, completion: @escaping (Result<UserProfile, Error>) -> ())

    Parameters

    userProfile

    The user profile to store.

    completion

    The completion handler to be notified of the result. The completion handler contains either the user profile or an error.

  • Saves the modified user profile back to persistent storage.

    Throws

    An error if saving the modified profile fails.

    Declaration

    Swift

    @discardableResult
    func storeUserProfile(_ userProfile: UserProfile) throws -> UserProfile

    Parameters

    userProfile

    User profile to save back.

    Return Value

    the user profile representing the stored state.

  • Clears the user profile from persistent storage.

    Declaration

    Swift

    func clearUserProfile(completion: @escaping (Result<(), Error>) -> ())

    Parameters

    completion

    Completion handler that gets called after clearing the user profile.

  • Clears the user profile from persistent storage.

    Throws

    An error if clearing the user profile fails.

    Declaration

    Swift

    func clearUserProfile() throws
  • Add an observer to be notified of any changes to any of the data within the user profile. Updates might either originate from direct user interaction (calling the storeUserProfile method), indirectly through interaction with other parts of the application (starting navigation leading to a new recent destination) or from a remote system (user interaction in a companion app or inference models based on user behavior).

    Note

    PersonalData doesn’t retain observer objects. Please make sure that both the observer and the PersonalData instance itself are retained for as long as you need to receive updates.

    Declaration

    Swift

    func addUserProfileUpdateObserver(_ observer: UserProfileUpdateObserver)

    Parameters

    observer

    Observer that gets up-to-date user profile.

  • Removes an update observer for changes to any of the data within the user profile.

    Declaration

    Swift

    func removeUserProfileUpdateObserver(_ observer: UserProfileUpdateObserver)

    Parameters

    observer

    previously added observer to remove.