HistoryRecording
public protocol HistoryRecording
Types that conform to this protocol record low-level details as the user goes through a trip for debugging purposes.
-
A closure to be called when history writing ends.
Declaration
Swift
typealias HistoryFileWritingCompletionHandler = (_ historyFileURL: URL?) -> Void
Parameters
historyFileURL
A URL to the file that contains history data. This argument is
nil
if no history data has been written because history recording has not yet begun. Use thestartRecordingHistory()
method to begin recording before attempting to write a history file. -
historyDirectoryURL
Default implementationPath to the directory where history file could be stored when
stopRecordingHistory(writingFileWith:)
is called.Setting
nil
disables history recording. Defaults tonil
. Updating value fromnil
tonon-nil
value results in recreating the shared instance sincenil
guaranteed an invalid handler. Further updates have no effect. Saved history files can be then read usingHistoryReader
.Default Implementation
Declaration
Swift
static var historyDirectoryURL: URL? { get set }
-
startRecordingHistory()
Default implementationStarts recording history for debugging purposes.
Postcondition
Use thestopRecordingHistory(writingFileWith:)
method to stop recording history and write the recorded history to a file.Default Implementation
Declaration
Swift
static func startRecordingHistory()
-
startRecordingHistory()
Default implementationStarts recording history for debugging purposes.
Postcondition
Use thestopRecordingHistory(writingFileWith:)
method to stop recording history and write the recorded history to a file.Default Implementation
Declaration
Swift
@available(*, deprecated, message: "Use corresponding static method instead.") func startRecordingHistory()
-
pushHistoryEvent(type:jsonData:)
Default implementationAppends a custom event to the current history log. This can be useful to log things that happen during navigation that are specific to your application.
Precondition
Use the
startRecordingHistory()
method to begin recording history. If thestartRecordingHistory()
method has not been called, this method has no effect.Default Implementation
Declaration
Swift
static func pushHistoryEvent(type: String, jsonData: Data?) throws
Parameters
type
The event type in the events log for your custom event.
jsonData
The data value that contains a valid JSON to attach to the event.
-
pushHistoryEvent(type:jsonData:)
Default implementationAppends a custom event to the current history log. This can be useful to log things that happen during navigation that are specific to your application.
Precondition
Use the
startRecordingHistory()
method to begin recording history. If thestartRecordingHistory()
method has not been called, this method has no effect.Default Implementation
Declaration
Swift
@available(*, deprecated, message: "Use corresponding static method instead.") func pushHistoryEvent(type: String, jsonData: Data?) throws
Parameters
type
The event type in the events log for your custom event.
jsonData
The data value that contains a valid JSON to attach to the event.
-
stopRecordingHistory(writingFileWith:)
Default implementationStops recording history, asynchronously writing any recorded history to a file.
Upon completion, the completion handler is called with the URL to a file in the directory specified by
historyDirectoryURL
. The file contains details about the passive location manager’s activity that may be useful to include when reporting an issue to Mapbox.Saved history files can be then read using
HistoryReader
.Precondition
Use thestartRecordingHistory()
method to begin recording history. If thestartRecordingHistory()
method has not been called, this method has no effect.Postcondition
To write history incrementally without an interruption in history recording, use the
startRecordingHistory()
method immediately after this method. If you use thestartRecordingHistory()
method inside the completion handler of this method, history recording will be paused while the file is being prepared.Default Implementation
Declaration
Swift
static func stopRecordingHistory(writingFileWith completionHandler: @escaping HistoryFileWritingCompletionHandler)
Parameters
completionHandler
A closure to be executed when the history file is ready.
-
stopRecordingHistory(writingFileWith:)
Default implementationStops recording history, asynchronously writing any recorded history to a file.
Upon completion, the completion handler is called with the URL to a file in the directory specified by
historyDirectoryURL
. The file contains details about the passive location manager’s activity that may be useful to include when reporting an issue to Mapbox.Precondition
Use thestartRecordingHistory()
method to begin recording history. If thestartRecordingHistory()
method has not been called, this method has no effect.Postcondition
To write history incrementally without an interruption in history recording, use the
startRecordingHistory()
method immediately after this method. If you use thestartRecordingHistory()
method inside the completion handler of this method, history recording will be paused while the file is being prepared.Default Implementation
Declaration
Swift
@available(*, deprecated, message: "Use corresponding static method instead.") func stopRecordingHistory(writingFileWith completionHandler: @escaping HistoryFileWritingCompletionHandler)
Parameters
completionHandler
A closure to be executed when the history file is ready.
-
startRecordingHistoryImplementation()
Extension methodDeclaration
Swift
static func startRecordingHistoryImplementation()
-
pushHistoryEvent(type:value:encoder:)
Extension methodAppends a custom event to the current history log. This can be useful to log things that happen during navigation that are specific to your application.
Precondition
Use the
startRecordingHistory()
method to begin recording history. If thestartRecordingHistory()
method has not been called, this method has no effect.Declaration
Swift
static func pushHistoryEvent<Value>(type: String, value: Value?, encoder: JSONEncoder? = nil) throws where Value : Encodable
Parameters
type
The event type in the events log for your custom event.
value
The value that implements
Encodable
protocol and can be encoded into a valid JSON to attach to the event.encoder
The instance of
JSONEncoder
to be used for the value encoding. If this argument is omitted, the defaultJSONEncoder
will be used. -
pushHistoryEvent(type:value:encoder:)
Extension methodAppends a custom event to the current history log. This can be useful to log things that happen during navigation that are specific to your application.
Precondition
Use the
startRecordingHistory()
method to begin recording history. If thestartRecordingHistory()
method has not been called, this method has no effect.Declaration
Swift
@available(*, deprecated, message: "Use corresponding static method instead.") func pushHistoryEvent<Value>(type: String, value: Value?, encoder: JSONEncoder? = nil) throws where Value : Encodable
Parameters
type
The event type in the events log for your custom event.
value
The value that implements
Encodable
protocol and can be encoded into a valid JSON to attach to the event.encoder
The instance of
JSONEncoder
to be used for the value encoding. If this argument is omitted, the defaultJSONEncoder
will be used. -
pushHistoryEvent(type:dictionary:)
Extension methodAppends a custom event to the current history log. This can be useful to log things that happen during navigation that are specific to your application.
Precondition
Use the
startRecordingHistory()
method to begin recording history. If thestartRecordingHistory()
method has not been called, this method has no effect.Declaration
Swift
static func pushHistoryEvent(type: String, dictionary value: [String : Any?]?) throws
Parameters
type
The event type in the events log for your custom event.
value
The value disctionary that can be encoded into a JSON to attach to the event.
-
pushHistoryEvent(type:dictionary:)
Extension methodAppends a custom event to the current history log. This can be useful to log things that happen during navigation that are specific to your application.
Precondition
Use the
startRecordingHistory()
method to begin recording history. If thestartRecordingHistory()
method has not been called, this method has no effect.Declaration
Swift
@available(*, deprecated, message: "Use corresponding static method instead.") func pushHistoryEvent(type: String, dictionary value: [String : Any?]?) throws
Parameters
type
The event type in the events log for your custom event.
value
The value disctionary that can be encoded into a JSON to attach to the event.