fix: send HardwareId to register_beacon_hardware API
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) <noreply@anthropic.com>
This commit is contained in:
parent
ce81a1a3d8
commit
157ab6d008
2 changed files with 6 additions and 5 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue