설명 없음

FIRAuthAPNSTokenManager.h 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright 2017 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. #import <UIKit/UIKit.h>
  18. @class FIRAuthAPNSToken;
  19. NS_ASSUME_NONNULL_BEGIN
  20. /** @typedef FIRAuthAPNSTokenCallback
  21. @brief The type of block to receive an APNs token.
  22. @param token The APNs token if one is available.
  23. @param error The error happened if any.
  24. @remarks Both `token` and `error` being `nil` means the request timed-out.
  25. */
  26. typedef void (^FIRAuthAPNSTokenCallback)(FIRAuthAPNSToken *_Nullable token,
  27. NSError *_Nullable error);
  28. /** @class FIRAuthAPNSTokenManager
  29. @brief A class to manage APNs token in memory.
  30. */
  31. @interface FIRAuthAPNSTokenManager : NSObject
  32. /** @property token
  33. @brief The APNs token, if one is available.
  34. @remarks Setting a token with FIRAuthAPNSTokenTypeUnknown will automatically converts it to
  35. a token with the automatically detected type.
  36. */
  37. @property(nonatomic, strong, nullable) FIRAuthAPNSToken *token;
  38. /** @property timeout
  39. @brief The timeout for registering for remote notification.
  40. @remarks Only tests should access this property.
  41. */
  42. @property(nonatomic, assign) NSTimeInterval timeout;
  43. /** @fn init
  44. @brief Call @c initWithApplication: to initialize an instance of this class.
  45. */
  46. - (instancetype)init NS_UNAVAILABLE;
  47. /** @fn initWithApplication:bundle
  48. @brief Initializes the instance.
  49. @param application The @c UIApplication to request the token from.
  50. @return The initialized instance.
  51. */
  52. - (instancetype)initWithApplication:(UIApplication *)application NS_DESIGNATED_INITIALIZER;
  53. /** @fn getTokenWithCallback:
  54. @brief Attempts to get the APNs token.
  55. @param callback The block to be called either immediately or in future, either when a token
  56. becomes available, or when timeout occurs, whichever happens earlier.
  57. */
  58. - (void)getTokenWithCallback:(FIRAuthAPNSTokenCallback)callback;
  59. /** @fn cancelWithError:
  60. @brief Cancels any pending `getTokenWithCallback:` request.
  61. @param error The error to return.
  62. */
  63. - (void)cancelWithError:(NSError *)error;
  64. @end
  65. NS_ASSUME_NONNULL_END