SDK iOS / Swift
SDK nativo para plataformas Apple con soporte completo para Swift concurrency (async/await). Compatible con iOS, macOS, tvOS y watchOS.
SPM: EcfDgiiClientGitHub
Requisitos
- iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+
- Swift 6.0+
- Xcode 16.0+
Instalación
Swift Package Manager (recomendado):
En Xcode, vaya a File → Add Package Dependencies y agregue:
bash
https://github.com/puntoos/ecf-dgii-swift.git
CocoaPods:
bash
pod 'EcfDgiiClient'
Uso rápido
python
import EcfDgiiClientlet client = EcfClient(baseUrl: "https://api.test.ecfx.ssd.com.do",apiKey: "tu-api-key")// Enviar ECF con polling automáticolet result = try await client.sendEcf(rnc: "rnc-empresa", ecf: ecfData)print(result.impresionUrl) // URL del QRprint(result.codSec) // Código de seguridadprint(result.fechaFirma) // Fecha de firma
Cancelación
El SDK soporta cancelación cooperativa usando Task.cancel():
swift
let task = Task {let result = try await client.sendEcf(rnc: "rnc", ecf: ecfData)// procesar resultado}// Cancelar si es necesariotask.cancel()
Cliente Frontend
El EcfFrontendClient usa Keychain para el cache de tokens por defecto, proporcionando almacenamiento seguro en dispositivos Apple.
swift
let frontend = EcfFrontendClient(baseUrl: "https://api.prod.ecfx.ssd.com.do",getToken: { try await fetchTokenFromBackend() })// Consultar estado (solo lectura)let status = try await frontend.getEcfStatus(trackId: "abc-123")
APIs disponibles
El SDK expone endpoints completos para ECF, Company, DGII y Recepción con documentación inline en Xcode.