FIRAppDistribution.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. @class FIRAppDistributionRelease;
  15. @class UIApplication;
  16. #import <Foundation/Foundation.h>
  17. NS_ASSUME_NONNULL_BEGIN
  18. /**
  19. * The Firebase App Distribution API provides methods to check for update to
  20. * the app and returns information that enables updating the app.
  21. *
  22. * By default, Firebase App Distribution is initialized with `FirebaseApp.configure()`.
  23. *
  24. * Note: The App Distribution class cannot be subclassed. If this makes testing difficult,
  25. * we suggest using a wrapper class or a protocol extension.
  26. */
  27. NS_EXTENSION_UNAVAILABLE_IOS("Firebase App Distribution is not supported for iOS extensions.")
  28. NS_SWIFT_NAME(AppDistribution)
  29. @interface FIRAppDistribution : NSObject
  30. /// Returns true if the App Distribution tester is signed in.
  31. @property(nonatomic, readonly) BOOL isTesterSignedIn;
  32. /** :nodoc: */
  33. - (instancetype)init NS_UNAVAILABLE;
  34. /**
  35. * Sign-in the App Distribution tester
  36. */
  37. - (void)signInTesterWithCompletion:(void (^)(NSError *_Nullable error))completion
  38. NS_SWIFT_NAME(signInTester(completion:));
  39. /**
  40. * Check to see whether a new distribution is available
  41. */
  42. - (void)checkForUpdateWithCompletion:(void (^)(FIRAppDistributionRelease *_Nullable_result release,
  43. NSError *_Nullable error))completion
  44. NS_SWIFT_NAME(checkForUpdate(completion:));
  45. /**
  46. * Sign out App Distribution tester
  47. */
  48. - (void)signOutTester;
  49. /**
  50. * Handle an App Distribution URL, for example a link to download a new pre-release version.
  51. * Call this method in your app delegate's `openURL` implementation if swizzling is disabled.
  52. */
  53. - (BOOL)application:(UIApplication *)application
  54. openURL:(NSURL *)url
  55. options:(NSDictionary<NSString *, id> *)options;
  56. /**
  57. * Accesses the singleton App Distribution instance.
  58. *
  59. * @return The singleton App Distribution instance.
  60. */
  61. + (instancetype)appDistribution NS_SWIFT_NAME(appDistribution());
  62. @end
  63. /// The error domain for codes in the `FIRAppDistributionError` enum.
  64. // clang-format off
  65. // clang-format12 will merge lines and exceed 100 character limit.
  66. FOUNDATION_EXPORT NSString *const FIRAppDistributionErrorDomain
  67. NS_SWIFT_NAME(AppDistributionErrorDomain);
  68. /// The key for finding error details in the `NSError`'s `userInfo`.
  69. FOUNDATION_EXPORT NSString *const FIRAppDistributionErrorDetailsKey
  70. NS_SWIFT_NAME(AppDistributionErrorDetailsKey);
  71. // clang-format on
  72. /**
  73. * Error codes representing sign in or version check failure reasons.
  74. */
  75. typedef NS_ERROR_ENUM(FIRAppDistributionErrorDomain, FIRAppDistributionError){
  76. /// Returned when an unknown error occurred.
  77. FIRAppDistributionErrorUnknown = 0,
  78. /// Returned when App Distribution failed to authenticate the user.
  79. FIRAppDistributionErrorAuthenticationFailure = 1,
  80. /// Returned when sign-in was cancelled.
  81. FIRAppDistributionErrorAuthenticationCancelled = 2,
  82. /// Returned when the network was unavailable to make requests or
  83. /// the request timed out.
  84. FIRAppDistributionErrorNetworkFailure = 3,
  85. } NS_SWIFT_NAME(AppDistributionError);
  86. NS_ASSUME_NONNULL_END