AuthAPNSToken.swift 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2023 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #if !os(macOS)
  15. import Foundation
  16. // TODO: Eliminate objc public after Sample app port.
  17. /** @class AuthAPNSToken
  18. @brief A data structure for an APNs token.
  19. */
  20. @objc(FIRAuthAPNSToken) public class AuthAPNSToken: NSObject {
  21. @objc public let data: Data
  22. @objc public let type: AuthAPNSTokenType
  23. /** @fn initWithData:type:
  24. @brief Initializes the instance.
  25. @param data The APNs token data.
  26. @param type The APNs token type.
  27. @return The initialized instance.
  28. */
  29. init(withData data: Data, type: AuthAPNSTokenType) {
  30. self.data = data
  31. self.type = type
  32. }
  33. /** @property string
  34. @brief The uppercase hexadecimal string form of the APNs token data.
  35. */
  36. @objc public lazy var string: String = {
  37. let byteArray = [UInt8](data)
  38. var s = ""
  39. for byte in byteArray {
  40. s.append(String(format: "%02X", byte))
  41. }
  42. return s
  43. }()
  44. }
  45. #endif