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.

83 lines
2.7 KiB

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