You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.6 KiB

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