Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Native BLE transport for Ledger device communication over BLE

License

Notifications You must be signed in to change notification settings

LedgerHQ/hw-transport-ios-ble

Repository files navigation

GitHub, Ledger Devs Discord, Developer Portal

BleTransport (beta)

Allows for communication with Ledger Hardware Wallets via BLE (Bluetooth Low Energy) on iOS (>=13.0) and macOS (>=12.0). Please note that this is a beta release and still under active development.

Usage

The demo application is the best way to see BleTransport in action. Simply open the BleTransport.xcodeproj and run the BleTransportDemo or BleTransportDemoMac scheme.

Basic example:

import BleTransport

BleTransport.shared.scan(duration: 30.0) { discoveries in
    guard let id = discoveries.first?.peripheral else {
        return
    }

    BleTransport.shared.connect(toPeripheralID: id, disconnectedCallback: nil) { peripheral in
        print("Connected to device: \(peripheral.name)")
    } failure: { error in
        print("Error while connecting: \(error)")
    }

} stopped: { error in
    print("Error while scanning: \(error)")
}

Installation

Swift Package Manager

To integrate using Apple's Swift Package Manager, add the following as a dependency to your Package.swift:

dependencies: [
    .package(url: "https://github.com/LedgerHQ/hw-transport-ios-ble.git", from: "1.0.0")
]