FIRHTTPSCallable.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Copyright 2017 Google
  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. #import <Foundation/Foundation.h>
  15. NS_ASSUME_NONNULL_BEGIN
  16. /**
  17. * A `FIRHTTPSCallableResult` contains the result of calling a `FIRHTTPSCallable`.
  18. */
  19. NS_SWIFT_NAME(HTTPSCallableResult)
  20. @interface FIRHTTPSCallableResult : NSObject
  21. - (id)init NS_UNAVAILABLE;
  22. /**
  23. * The data that was returned from the Callable HTTPS trigger.
  24. *
  25. * The data is in the form of native objects. For example, if your trigger returned an
  26. * array, this object would be an NSArray. If your trigger returned a JavaScript object with
  27. * keys and values, this object would be an NSDictionary.
  28. */
  29. @property(nonatomic, strong, readonly) id data;
  30. @end
  31. /**
  32. * A `FIRHTTPSCallable` is reference to a particular Callable HTTPS trigger in Cloud Functions.
  33. */
  34. NS_SWIFT_NAME(HTTPSCallable)
  35. @interface FIRHTTPSCallable : NSObject
  36. - (id)init NS_UNAVAILABLE;
  37. /**
  38. * Executes this Callable HTTPS trigger asynchronously without any parameters.
  39. *
  40. * The request to the Cloud Functions backend made by this method automatically includes a
  41. * Firebase Instance ID token to identify the app instance. If a user is logged in with Firebase
  42. * Auth, an auth ID token for the user is also automatically included.
  43. *
  44. * Firebase Instance ID sends data to the Firebase backend periodically to collect information
  45. * regarding the app instance. To stop this, see `[FIRInstanceID deleteIDWithHandler:]`. It
  46. * resumes with a new Instance ID the next time you call this method.
  47. *
  48. * @param completion The block to call when the HTTPS request has completed.
  49. */
  50. - (void)callWithCompletion:
  51. (void (^)(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error))completion
  52. NS_SWIFT_NAME(call(completion:));
  53. /**
  54. * Executes this Callable HTTPS trigger asynchronously.
  55. *
  56. * The data passed into the trigger can be any of the following types:
  57. * * NSNull
  58. * * NSString
  59. * * NSNumber
  60. * * NSArray<id>, where the contained objects are also one of these types.
  61. * * NSDictionary<NSString, id>, where the values are also one of these types.
  62. *
  63. * The request to the Cloud Functions backend made by this method automatically includes a
  64. * Firebase Instance ID token to identify the app instance. If a user is logged in with Firebase
  65. * Auth, an auth ID token for the user is also automatically included.
  66. *
  67. * Firebase Instance ID sends data to the Firebase backend periodically to collect information
  68. * regarding the app instance. To stop this, see `[FIRInstanceID deleteIDWithHandler:]`. It
  69. * resumes with a new Instance ID the next time you call this method.
  70. *
  71. * @param data Parameters to pass to the trigger.
  72. * @param completion The block to call when the HTTPS request has completed.
  73. */
  74. // clang-format off
  75. // because it incorrectly breaks this NS_SWIFT_NAME.
  76. - (void)callWithObject:(nullable id)data
  77. completion:(void (^)(FIRHTTPSCallableResult *_Nullable result,
  78. NSError *_Nullable error))completion
  79. NS_SWIFT_NAME(call(_:completion:));
  80. // clang-format on
  81. /**
  82. * The timeout to use when calling the function. Defaults to 60 seconds.
  83. */
  84. @property(nonatomic, assign) NSTimeInterval timeoutInterval;
  85. @end
  86. NS_ASSUME_NONNULL_END