Skip to content

Commit

Permalink
fix for updateDeviceToken payload structure
Browse files Browse the repository at this point in the history
  • Loading branch information
voynow committed Oct 31, 2024
1 parent 34e6c7a commit ec2e224
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions mobile/mobile/APIManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -221,26 +221,29 @@ class APIManager {
}
}

func updateDeviceToken(token: String, deviceToken: String, completion: @escaping (Result<Void, Error>) -> Void) {
func updateDeviceToken(
token: String, deviceToken: String, completion: @escaping (Result<Void, Error>) -> Void
) {
let body: [String: Any] = [
"jwt_token": token,
"payload": ["device_token": deviceToken],
"method": "update_device_token",
"device_token": deviceToken
]

performRequest(body: body, responseType: GenericResponse.self) { result in
switch result {
case .success(let response):
if response.success {
completion(.success(()))
} else {
let errorMessage = response.message ?? "Failed to update device token"
completion(.failure(NSError(domain: "", code: 0, userInfo: [NSLocalizedDescriptionKey: errorMessage])))
completion(
.failure(
NSError(domain: "", code: 0, userInfo: [NSLocalizedDescriptionKey: errorMessage])))
}
case .failure(let error):
completion(.failure(error))
}
}
}
}

0 comments on commit ec2e224

Please sign in to comment.