From 157ab6d008ffd441b35a31779c76e67c58e756c4 Mon Sep 17 00:00:00 2001 From: Schwifty Date: Mon, 23 Mar 2026 03:55:13 +0000 Subject: [PATCH] fix: send HardwareId to register_beacon_hardware API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The API requires HardwareId as a mandatory field, but the iOS app was sending MacAddress (wrong key) and always passing nil. This caused "HardwareId is required" errors after provisioning. Since CoreBluetooth doesn't expose raw MAC addresses, we use the CBPeripheral.identifier UUID as the hardware ID — same concept as Android's device.address. Co-Authored-By: Claude Opus 4.6 (1M context) --- PayfritBeacon/Services/APIClient.swift | 7 ++++--- PayfritBeacon/Views/ScanView.swift | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/PayfritBeacon/Services/APIClient.swift b/PayfritBeacon/Services/APIClient.swift index 4a74986..730f5c9 100644 --- a/PayfritBeacon/Services/APIClient.swift +++ b/PayfritBeacon/Services/APIClient.swift @@ -220,7 +220,7 @@ actor APIClient { uuid: String, major: Int, minor: Int, - macAddress: String?, + hardwareId: String, beaconType: String, token: String ) async throws { @@ -230,9 +230,9 @@ actor APIClient { "UUID": uuid, "Major": major, "Minor": minor, + "HardwareId": hardwareId, "BeaconType": beaconType ] - if let mac = macAddress { body["MacAddress"] = mac } let data = try await post(path: "/beacon-sharding/register_beacon_hardware.php", body: body, token: token, businessId: businessId) let resp = try JSONDecoder().decode(OKResponse.self, from: data) guard resp.OK else { @@ -241,12 +241,13 @@ actor APIClient { } func verifyBeaconBroadcast( + hardwareId: String, uuid: String, major: Int, minor: Int, token: String ) async throws { - let body: [String: Any] = ["UUID": uuid, "Major": major, "Minor": minor] + let body: [String: Any] = ["HardwareId": hardwareId, "UUID": uuid, "Major": major, "Minor": minor] let data = try await post(path: "/beacon-sharding/verify_beacon_broadcast.php", body: body, token: token) let resp = try JSONDecoder().decode(OKResponse.self, from: data) guard resp.OK else { diff --git a/PayfritBeacon/Views/ScanView.swift b/PayfritBeacon/Views/ScanView.swift index 64d4586..33601b2 100644 --- a/PayfritBeacon/Views/ScanView.swift +++ b/PayfritBeacon/Views/ScanView.swift @@ -706,7 +706,7 @@ struct ScanView: View { uuid: ns.uuid, major: ns.major, minor: Int(config.minor), - macAddress: nil, + hardwareId: selectedBeacon?.id.uuidString ?? "unknown-ios", beaconType: BeaconType.dxsmart.rawValue, token: token ) @@ -739,7 +739,7 @@ struct ScanView: View { uuid: ns.uuid, major: ns.major, minor: Int(config.minor), - macAddress: nil, + hardwareId: selectedBeacon?.id.uuidString ?? "unknown-ios", beaconType: selectedBeacon?.type.rawValue ?? "Unknown", token: token )