No Description

FIRInstanceIDTokenOperation.h 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 <Foundation/Foundation.h>
  17. @class FIRInstanceIDKeyPair;
  18. @class FIRInstanceIDCheckinPreferences;
  19. NS_ASSUME_NONNULL_BEGIN
  20. /**
  21. * Represents the action taken on an FCM token.
  22. */
  23. typedef NS_ENUM(NSInteger, FIRInstanceIDTokenAction) {
  24. FIRInstanceIDTokenActionFetch,
  25. FIRInstanceIDTokenActionDeleteToken,
  26. FIRInstanceIDTokenActionDeleteTokenAndIID,
  27. };
  28. /**
  29. * Represents the possible results of a token operation.
  30. */
  31. typedef NS_ENUM(NSInteger, FIRInstanceIDTokenOperationResult) {
  32. FIRInstanceIDTokenOperationSucceeded,
  33. FIRInstanceIDTokenOperationError,
  34. FIRInstanceIDTokenOperationCancelled,
  35. };
  36. /**
  37. * Callback to invoke once the HTTP call to FIRMessaging backend for updating
  38. * subscription finishes.
  39. *
  40. * @param result The result of the operation.
  41. * @param token If the action for fetching a token and the request was successful, this will hold
  42. * the value of the token. Otherwise nil.
  43. * @param error The error which occurred while performing the token operation. This will be nil
  44. * in case the operation was successful, or if the operation was cancelled.
  45. */
  46. typedef void (^FIRInstanceIDTokenOperationCompletion)(FIRInstanceIDTokenOperationResult result,
  47. NSString *_Nullable token,
  48. NSError *_Nullable error);
  49. @interface FIRInstanceIDTokenOperation : NSOperation
  50. @property(nonatomic, readonly) FIRInstanceIDTokenAction action;
  51. @property(nonatomic, readonly, nullable) NSString *authorizedEntity;
  52. @property(nonatomic, readonly, nullable) NSString *scope;
  53. @property(nonatomic, readonly, nullable) NSDictionary<NSString *, NSString *> *options;
  54. @property(nonatomic, readonly, strong) FIRInstanceIDCheckinPreferences *checkinPreferences;
  55. @property(nonatomic, readonly, strong) FIRInstanceIDKeyPair *keyPair;
  56. @property(nonatomic, readonly) FIRInstanceIDTokenOperationResult result;
  57. - (instancetype)init NS_UNAVAILABLE;
  58. - (void)addCompletionHandler:(FIRInstanceIDTokenOperationCompletion)handler;
  59. @end
  60. NS_ASSUME_NONNULL_END