FIRInstallationsItem+RegisterInstallationAPI.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright 2019 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "FirebaseInstallations/Source/Library/FIRInstallationsItem.h"
  17. @class FIRInstallationsStoredAuthToken;
  18. NS_ASSUME_NONNULL_BEGIN
  19. @interface FIRInstallationsItem (RegisterInstallationAPI)
  20. /**
  21. * Parses and validates the Register Installation API response and returns a corresponding
  22. * `FIRInstallationsItem` instance on success.
  23. * @param JSONData The data with JSON encoded API response.
  24. * @param date The Auth Token expiration date will be calculated as `date` +
  25. * `response.authToken.expiresIn`. For most of the cases `[NSDate date]` should be passed there. A
  26. * different value may be passed e.g. for unit tests.
  27. * @param outError A pointer to assign a specific `NSError` instance in case of failure. No error is
  28. * assigned in case of success.
  29. * @return Returns a new `FIRInstallationsItem` instance in the success case or `nil` otherwise.
  30. */
  31. - (nullable FIRInstallationsItem *)registeredInstallationWithJSONData:(NSData *)JSONData
  32. date:(NSDate *)date
  33. error:
  34. (NSError *_Nullable *)outError;
  35. + (nullable FIRInstallationsStoredAuthToken *)authTokenWithGenerateTokenAPIJSONData:(NSData *)data
  36. date:(NSDate *)date
  37. error:(NSError **)
  38. outError;
  39. + (nullable FIRInstallationsStoredAuthToken *)authTokenWithJSONDict:
  40. (NSDictionary<NSString *, id> *)dict
  41. date:(NSDate *)date
  42. error:(NSError **)outError;
  43. @end
  44. NS_ASSUME_NONNULL_END