Create a singleton service:

public static let service = try! NotchAPI.Builder().build().service

If you want to develop without notches it is possible to use a ‘mock’ build of the service. All the service calls will return with success after a short delay. For this behavior create the service by setting the ‘isMock’ property to true:

public static let service = try! NotchAPI.Builder()
    .build(isMock: true)


Using the NotchService you can interact with the notches.

Each service call returns a NotchCancellable which has the .cancel() call to stop the process.

Each service call has four function parameters to act as callback functions:

Example for starting a timed capture:

    var currentCancellable = service.timedCapture(
        success: { result in
            self.currentMeasurement = result
            self.currentCancellable = nil
        failure: { result in
            switch result {
            case .UnknownError(let message)
                self.showCaptureFailedAlert(message: message)
                self.showCaptureFailedAlert(message: "Internal error")
            self.currentCancellable = nil
        progress: { _ in // ignore the parameter
        cancelled: {
            currentCancellable = nil 

Anytime you can cancel the operation by invoking the .cancel() operation on your saved cancellable:


IMPORTANT Do not cancel an already cancelled operation. It can cause inconsistency.


Each class that is used with the notch API has a ‘Notch’ prefix. These are usually abstractions of the real world objects. Such as a NotchSkeleton is what contains all the NotchBones, and a NotchBone has relation with a NotchDevice.

Service calls

Each service call happens on the background thread. The callbacks are always received on the same background thread, DO NOT forget to switch back to main thread if you perform actions on the UI.