FIRUser.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  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 "FIRAuth.h"
  18. #import "FIRAuthDataResult.h"
  19. #import "FIRMultiFactor.h"
  20. #import "FIRUserInfo.h"
  21. @class FIRAuthTokenResult;
  22. @class FIRPhoneAuthCredential;
  23. @class FIRUserProfileChangeRequest;
  24. @class FIRUserMetadata;
  25. @protocol FIRAuthUIDelegate;
  26. NS_ASSUME_NONNULL_BEGIN
  27. /** @typedef FIRAuthTokenCallback
  28. @brief The type of block called when a token is ready for use.
  29. @see FIRUser.getIDTokenWithCompletion:
  30. @see FIRUser.getIDTokenForcingRefresh:withCompletion:
  31. @param token Optionally; an access token if the request was successful.
  32. @param error Optionally; the error which occurred - or nil if the request was successful.
  33. @remarks One of: `token` or `error` will always be non-nil.
  34. */
  35. typedef void (^FIRAuthTokenCallback)(NSString *_Nullable token, NSError *_Nullable error)
  36. NS_SWIFT_NAME(AuthTokenCallback);
  37. /** @typedef FIRAuthTokenResultCallback
  38. @brief The type of block called when a token is ready for use.
  39. @see FIRUser.getIDTokenResultWithCompletion:
  40. @see FIRUser.getIDTokenResultForcingRefresh:withCompletion:
  41. @param tokenResult Optionally; an object containing the raw access token string as well as other
  42. useful data pertaining to the token.
  43. @param error Optionally; the error which occurred - or nil if the request was successful.
  44. @remarks One of: `token` or `error` will always be non-nil.
  45. */
  46. typedef void (^FIRAuthTokenResultCallback)(FIRAuthTokenResult *_Nullable tokenResult,
  47. NSError *_Nullable error)
  48. NS_SWIFT_NAME(AuthTokenResultCallback);
  49. /** @typedef FIRUserProfileChangeCallback
  50. @brief The type of block called when a user profile change has finished.
  51. @param error Optionally; the error which occurred - or nil if the request was successful.
  52. */
  53. typedef void (^FIRUserProfileChangeCallback)(NSError *_Nullable error)
  54. NS_SWIFT_NAME(UserProfileChangeCallback);
  55. /** @typedef FIRSendEmailVerificationCallback
  56. @brief The type of block called when a request to send an email verification has finished.
  57. @param error Optionally; the error which occurred - or nil if the request was successful.
  58. */
  59. typedef void (^FIRSendEmailVerificationCallback)(NSError *_Nullable error)
  60. NS_SWIFT_NAME(SendEmailVerificationCallback);
  61. /** @class FIRUser
  62. @brief Represents a user. Firebase Auth does not attempt to validate users
  63. when loading them from the keychain. Invalidated users (such as those
  64. whose passwords have been changed on another client) are automatically
  65. logged out when an auth-dependent operation is attempted or when the
  66. ID token is automatically refreshed.
  67. @remarks This class is thread-safe.
  68. */
  69. NS_SWIFT_NAME(User)
  70. @interface FIRUser : NSObject <FIRUserInfo>
  71. /** @property anonymous
  72. @brief Indicates the user represents an anonymous user.
  73. */
  74. @property(nonatomic, readonly, getter=isAnonymous) BOOL anonymous;
  75. /** @property emailVerified
  76. @brief Indicates the email address associated with this user has been verified.
  77. */
  78. @property(nonatomic, readonly, getter=isEmailVerified) BOOL emailVerified;
  79. /** @property refreshToken
  80. @brief A refresh token; useful for obtaining new access tokens independently.
  81. @remarks This property should only be used for advanced scenarios, and is not typically needed.
  82. */
  83. @property(nonatomic, readonly, nullable) NSString *refreshToken;
  84. /** @property providerData
  85. @brief Profile data for each identity provider, if any.
  86. @remarks This data is cached on sign-in and updated when linking or unlinking.
  87. */
  88. @property(nonatomic, readonly, nonnull) NSArray<id<FIRUserInfo>> *providerData;
  89. /** @property metadata
  90. @brief Metadata associated with the Firebase user in question.
  91. */
  92. @property(nonatomic, readonly, nonnull) FIRUserMetadata *metadata;
  93. /** @property tenantID
  94. @brief The tenant ID of the current user. nil if none is available.
  95. */
  96. @property(nonatomic, readonly, nullable) NSString *tenantID;
  97. #if TARGET_OS_IOS
  98. /** @property multiFactor
  99. @brief Multi factor object associated with the user.
  100. */
  101. @property(nonatomic, readonly, nonnull) FIRMultiFactor *multiFactor;
  102. #endif
  103. /** @fn init
  104. @brief This class should not be instantiated.
  105. @remarks To retrieve the current user, use `FIRAuth.currentUser`. To sign a user
  106. in or out, use the methods on `FIRAuth`.
  107. */
  108. - (instancetype)init NS_UNAVAILABLE;
  109. /** @fn updateEmail:completion:
  110. @brief Updates the email address for the user. On success, the cached user profile data is
  111. updated.
  112. @remarks May fail if there is already an account with this email address that was created using
  113. email and password authentication.
  114. @param email The email address for the user.
  115. @param completion Optionally; the block invoked when the user profile change has finished.
  116. Invoked asynchronously on the main thread in the future.
  117. @remarks Possible error codes:
  118. + `FIRAuthErrorCodeInvalidRecipientEmail` - Indicates an invalid recipient email was
  119. sent in the request.
  120. + `FIRAuthErrorCodeInvalidSender` - Indicates an invalid sender email is set in
  121. the console for this action.
  122. + `FIRAuthErrorCodeInvalidMessagePayload` - Indicates an invalid email template for
  123. sending update email.
  124. + `FIRAuthErrorCodeEmailAlreadyInUse` - Indicates the email is already in use by another
  125. account.
  126. + `FIRAuthErrorCodeInvalidEmail` - Indicates the email address is malformed.
  127. + `FIRAuthErrorCodeRequiresRecentLogin` - Updating a user’s email is a security
  128. sensitive operation that requires a recent login from the user. This error indicates
  129. the user has not signed in recently enough. To resolve, reauthenticate the user by
  130. invoking reauthenticateWithCredential:completion: on FIRUser.
  131. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  132. */
  133. - (void)updateEmail:(NSString *)email
  134. completion:(nullable void (^)(NSError *_Nullable error))completion
  135. NS_SWIFT_NAME(updateEmail(to:completion:));
  136. /** @fn updatePassword:completion:
  137. @brief Updates the password for the user. On success, the cached user profile data is updated.
  138. @param password The new password for the user.
  139. @param completion Optionally; the block invoked when the user profile change has finished.
  140. Invoked asynchronously on the main thread in the future.
  141. @remarks Possible error codes:
  142. + `FIRAuthErrorCodeOperationNotAllowed` - Indicates the administrator disabled
  143. sign in with the specified identity provider.
  144. + `FIRAuthErrorCodeRequiresRecentLogin` - Updating a user’s password is a security
  145. sensitive operation that requires a recent login from the user. This error indicates
  146. the user has not signed in recently enough. To resolve, reauthenticate the user by
  147. invoking reauthenticateWithCredential:completion: on FIRUser.
  148. + `FIRAuthErrorCodeWeakPassword` - Indicates an attempt to set a password that is
  149. considered too weak. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfo
  150. dictionary object will contain more detailed explanation that can be shown to the user.
  151. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  152. */
  153. - (void)updatePassword:(NSString *)password
  154. completion:(nullable void (^)(NSError *_Nullable error))completion
  155. NS_SWIFT_NAME(updatePassword(to:completion:));
  156. #if TARGET_OS_IOS
  157. /** @fn updatePhoneNumberCredential:completion:
  158. @brief Updates the phone number for the user. On success, the cached user profile data is
  159. updated.
  160. @param phoneNumberCredential The new phone number credential corresponding to the phone number
  161. to be added to the Firebase account, if a phone number is already linked to the account this
  162. new phone number will replace it.
  163. @param completion Optionally; the block invoked when the user profile change has finished.
  164. Invoked asynchronously on the main thread in the future.
  165. @remarks Possible error codes:
  166. + `FIRAuthErrorCodeRequiresRecentLogin` - Updating a user’s phone number is a security
  167. sensitive operation that requires a recent login from the user. This error indicates
  168. the user has not signed in recently enough. To resolve, reauthenticate the user by
  169. invoking reauthenticateWithCredential:completion: on FIRUser.
  170. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  171. */
  172. - (void)updatePhoneNumberCredential:(FIRPhoneAuthCredential *)phoneNumberCredential
  173. completion:(nullable void (^)(NSError *_Nullable error))completion;
  174. #endif
  175. /** @fn profileChangeRequest
  176. @brief Creates an object which may be used to change the user's profile data.
  177. @remarks Set the properties of the returned object, then call
  178. `FIRUserProfileChangeRequest.commitChangesWithCallback:` to perform the updates atomically.
  179. @return An object which may be used to change the user's profile data atomically.
  180. */
  181. - (FIRUserProfileChangeRequest *)profileChangeRequest NS_SWIFT_NAME(createProfileChangeRequest());
  182. /** @fn reloadWithCompletion:
  183. @brief Reloads the user's profile data from the server.
  184. @param completion Optionally; the block invoked when the reload has finished. Invoked
  185. asynchronously on the main thread in the future.
  186. @remarks May fail with a `FIRAuthErrorCodeRequiresRecentLogin` error code. In this case
  187. you should call `FIRUser.reauthenticateWithCredential:completion:` before re-invoking
  188. `FIRUser.updateEmail:completion:`.
  189. @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
  190. */
  191. - (void)reloadWithCompletion:(nullable void (^)(NSError *_Nullable error))completion;
  192. /** @fn reauthenticateWithCredential:completion:
  193. @brief Renews the user's authentication tokens by validating a fresh set of credentials supplied
  194. by the user and returns additional identity provider data.
  195. @param credential A user-supplied credential, which will be validated by the server. This can be
  196. a successful third-party identity provider sign-in, or an email address and password.
  197. @param completion Optionally; the block invoked when the re-authentication operation has
  198. finished. Invoked asynchronously on the main thread in the future.
  199. @remarks If the user associated with the supplied credential is different from the current user,
  200. or if the validation of the supplied credentials fails; an error is returned and the current
  201. user remains signed in.
  202. @remarks Possible error codes:
  203. + `FIRAuthErrorCodeInvalidCredential` - Indicates the supplied credential is invalid.
  204. This could happen if it has expired or it is malformed.
  205. + `FIRAuthErrorCodeOperationNotAllowed` - Indicates that accounts with the
  206. identity provider represented by the credential are not enabled. Enable them in the
  207. Auth section of the Firebase console.
  208. + `FIRAuthErrorCodeEmailAlreadyInUse` - Indicates the email asserted by the credential
  209. (e.g. the email in a Facebook access token) is already in use by an existing account,
  210. that cannot be authenticated with this method. Call fetchProvidersForEmail for
  211. this user’s email and then prompt them to sign in with any of the sign-in providers
  212. returned. This error will only be thrown if the "One account per email address"
  213. setting is enabled in the Firebase console, under Auth settings. Please note that the
  214. error code raised in this specific situation may not be the same on Web and Android.
  215. + `FIRAuthErrorCodeUserDisabled` - Indicates the user's account is disabled.
  216. + `FIRAuthErrorCodeWrongPassword` - Indicates the user attempted reauthentication with
  217. an incorrect password, if credential is of the type EmailPasswordAuthCredential.
  218. + `FIRAuthErrorCodeUserMismatch` - Indicates that an attempt was made to
  219. reauthenticate with a user which is not the current user.
  220. + `FIRAuthErrorCodeInvalidEmail` - Indicates the email address is malformed.
  221. @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
  222. */
  223. - (void)reauthenticateWithCredential:(FIRAuthCredential *)credential
  224. completion:(nullable void (^)(FIRAuthDataResult *_Nullable authResult,
  225. NSError *_Nullable error))completion;
  226. /** @fn reauthenticateWithProvider:UIDelegate:completion:
  227. @brief Renews the user's authentication using the provided auth provider instance.
  228. @param provider An instance of an auth provider used to initiate the reauthenticate flow.
  229. @param UIDelegate Optionally an instance of a class conforming to the FIRAuthUIDelegate
  230. protocol, this is used for presenting the web context. If nil, a default FIRAuthUIDelegate
  231. will be used.
  232. @param completion Optionally; a block which is invoked when the reauthenticate flow finishes, or
  233. is canceled. Invoked asynchronously on the main thread in the future.
  234. */
  235. - (void)reauthenticateWithProvider:(id<FIRFederatedAuthProvider>)provider
  236. UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
  237. completion:(nullable void (^)(FIRAuthDataResult *_Nullable authResult,
  238. NSError *_Nullable error))completion
  239. NS_SWIFT_NAME(reauthenticate(with:uiDelegate:completion:));
  240. /** @fn getIDTokenResultWithCompletion:
  241. @brief Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
  242. @param completion Optionally; the block invoked when the token is available. Invoked
  243. asynchronously on the main thread in the future.
  244. @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
  245. */
  246. - (void)getIDTokenResultWithCompletion:(nullable void (^)(FIRAuthTokenResult *_Nullable tokenResult,
  247. NSError *_Nullable error))completion
  248. NS_SWIFT_NAME(getIDTokenResult(completion:));
  249. /** @fn getIDTokenResultForcingRefresh:completion:
  250. @brief Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
  251. @param forceRefresh Forces a token refresh. Useful if the token becomes invalid for some reason
  252. other than an expiration.
  253. @param completion Optionally; the block invoked when the token is available. Invoked
  254. asynchronously on the main thread in the future.
  255. @remarks The authentication token will be refreshed (by making a network request) if it has
  256. expired, or if `forceRefresh` is YES.
  257. @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
  258. */
  259. - (void)getIDTokenResultForcingRefresh:(BOOL)forceRefresh
  260. completion:(nullable void (^)(FIRAuthTokenResult *_Nullable tokenResult,
  261. NSError *_Nullable error))completion
  262. NS_SWIFT_NAME(getIDTokenResult(forcingRefresh:completion:));
  263. /** @fn getIDTokenWithCompletion:
  264. @brief Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
  265. @param completion Optionally; the block invoked when the token is available. Invoked
  266. asynchronously on the main thread in the future.
  267. @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
  268. */
  269. - (void)getIDTokenWithCompletion:
  270. (nullable void (^)(NSString *_Nullable token, NSError *_Nullable error))completion
  271. NS_SWIFT_NAME(getIDToken(completion:));
  272. /** @fn getIDTokenForcingRefresh:completion:
  273. @brief Retrieves the Firebase authentication token, possibly refreshing it if it has expired.
  274. @param forceRefresh Forces a token refresh. Useful if the token becomes invalid for some reason
  275. other than an expiration.
  276. @param completion Optionally; the block invoked when the token is available. Invoked
  277. asynchronously on the main thread in the future.
  278. @remarks The authentication token will be refreshed (by making a network request) if it has
  279. expired, or if `forceRefresh` is YES.
  280. @remarks See `FIRAuthErrors` for a list of error codes that are common to all API methods.
  281. */
  282. - (void)getIDTokenForcingRefresh:(BOOL)forceRefresh
  283. completion:(nullable void (^)(NSString *_Nullable token,
  284. NSError *_Nullable error))completion;
  285. /** @fn linkWithCredential:completion:
  286. @brief Associates a user account from a third-party identity provider with this user and
  287. returns additional identity provider data.
  288. @param credential The credential for the identity provider.
  289. @param completion Optionally; the block invoked when the unlinking is complete, or fails.
  290. Invoked asynchronously on the main thread in the future.
  291. @remarks Possible error codes:
  292. + `FIRAuthErrorCodeProviderAlreadyLinked` - Indicates an attempt to link a provider of a
  293. type already linked to this account.
  294. + `FIRAuthErrorCodeCredentialAlreadyInUse` - Indicates an attempt to link with a
  295. credential that has already been linked with a different Firebase account.
  296. + `FIRAuthErrorCodeOperationNotAllowed` - Indicates that accounts with the identity
  297. provider represented by the credential are not enabled. Enable them in the Auth section
  298. of the Firebase console.
  299. @remarks This method may also return error codes associated with updateEmail:completion: and
  300. updatePassword:completion: on FIRUser.
  301. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  302. */
  303. - (void)linkWithCredential:(FIRAuthCredential *)credential
  304. completion:(nullable void (^)(FIRAuthDataResult *_Nullable authResult,
  305. NSError *_Nullable error))completion;
  306. /** @fn linkWithProvider:UIDelegate:completion:
  307. @brief link the user with the provided auth provider instance.
  308. @param provider An instance of an auth provider used to initiate the link flow.
  309. @param UIDelegate Optionally an instance of a class conforming to the FIRAuthUIDelegate
  310. protocol, this is used for presenting the web context. If nil, a default FIRAuthUIDelegate
  311. will be used.
  312. @param completion Optionally; a block which is invoked when the link flow finishes, or
  313. is canceled. Invoked asynchronously on the main thread in the future.
  314. */
  315. - (void)linkWithProvider:(id<FIRFederatedAuthProvider>)provider
  316. UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
  317. completion:(nullable void (^)(FIRAuthDataResult *_Nullable authResult,
  318. NSError *_Nullable error))completion
  319. NS_SWIFT_NAME(link(with:uiDelegate:completion:));
  320. /** @fn unlinkFromProvider:completion:
  321. @brief Disassociates a user account from a third-party identity provider with this user.
  322. @param provider The provider ID of the provider to unlink.
  323. @param completion Optionally; the block invoked when the unlinking is complete, or fails.
  324. Invoked asynchronously on the main thread in the future.
  325. @remarks Possible error codes:
  326. + `FIRAuthErrorCodeNoSuchProvider` - Indicates an attempt to unlink a provider
  327. that is not linked to the account.
  328. + `FIRAuthErrorCodeRequiresRecentLogin` - Updating email is a security sensitive
  329. operation that requires a recent login from the user. This error indicates the user
  330. has not signed in recently enough. To resolve, reauthenticate the user by invoking
  331. reauthenticateWithCredential:completion: on FIRUser.
  332. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  333. */
  334. - (void)unlinkFromProvider:(NSString *)provider
  335. completion:(nullable void (^)(FIRUser *_Nullable user,
  336. NSError *_Nullable error))completion;
  337. /** @fn sendEmailVerificationWithCompletion:
  338. @brief Initiates email verification for the user.
  339. @param completion Optionally; the block invoked when the request to send an email verification
  340. is complete, or fails. Invoked asynchronously on the main thread in the future.
  341. @remarks Possible error codes:
  342. + `FIRAuthErrorCodeInvalidRecipientEmail` - Indicates an invalid recipient email was
  343. sent in the request.
  344. + `FIRAuthErrorCodeInvalidSender` - Indicates an invalid sender email is set in
  345. the console for this action.
  346. + `FIRAuthErrorCodeInvalidMessagePayload` - Indicates an invalid email template for
  347. sending update email.
  348. + `FIRAuthErrorCodeUserNotFound` - Indicates the user account was not found.
  349. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  350. */
  351. - (void)sendEmailVerificationWithCompletion:(nullable void (^)(NSError *_Nullable error))completion;
  352. /** @fn sendEmailVerificationWithActionCodeSettings:completion:
  353. @brief Initiates email verification for the user.
  354. @param actionCodeSettings An `FIRActionCodeSettings` object containing settings related to
  355. handling action codes.
  356. @remarks Possible error codes:
  357. + `FIRAuthErrorCodeInvalidRecipientEmail` - Indicates an invalid recipient email was
  358. sent in the request.
  359. + `FIRAuthErrorCodeInvalidSender` - Indicates an invalid sender email is set in
  360. the console for this action.
  361. + `FIRAuthErrorCodeInvalidMessagePayload` - Indicates an invalid email template for
  362. sending update email.
  363. + `FIRAuthErrorCodeUserNotFound` - Indicates the user account was not found.
  364. + `FIRAuthErrorCodeMissingIosBundleID` - Indicates that the iOS bundle ID is missing when
  365. a iOS App Store ID is provided.
  366. + `FIRAuthErrorCodeMissingAndroidPackageName` - Indicates that the android package name
  367. is missing when the `androidInstallApp` flag is set to true.
  368. + `FIRAuthErrorCodeUnauthorizedDomain` - Indicates that the domain specified in the
  369. continue URL is not allowlisted in the Firebase console.
  370. + `FIRAuthErrorCodeInvalidContinueURI` - Indicates that the domain specified in the
  371. continue URI is not valid.
  372. */
  373. - (void)sendEmailVerificationWithActionCodeSettings:(FIRActionCodeSettings *)actionCodeSettings
  374. completion:(nullable void (^)(NSError *_Nullable error))
  375. completion;
  376. /** @fn deleteWithCompletion:
  377. @brief Deletes the user account (also signs out the user, if this was the current user).
  378. @param completion Optionally; the block invoked when the request to delete the account is
  379. complete, or fails. Invoked asynchronously on the main thread in the future.
  380. @remarks Possible error codes:
  381. + `FIRAuthErrorCodeRequiresRecentLogin` - Updating email is a security sensitive
  382. operation that requires a recent login from the user. This error indicates the user
  383. has not signed in recently enough. To resolve, reauthenticate the user by invoking
  384. reauthenticateWithCredential:completion: on FIRUser.
  385. @remarks See `FIRAuthErrors` for a list of error codes that are common to all FIRUser methods.
  386. */
  387. - (void)deleteWithCompletion:(nullable void (^)(NSError *_Nullable error))completion;
  388. /** @fn sendEmailVerificationBeforeUpdatingEmail:completion:
  389. @brief Send an email to verify the ownership of the account then update to the new email.
  390. @param email The email to be updated to.
  391. @param completion Optionally; the block invoked when the request to send the verification
  392. email is complete, or fails.
  393. */
  394. - (void)sendEmailVerificationBeforeUpdatingEmail:(nonnull NSString *)email
  395. completion:
  396. (nullable void (^)(NSError *_Nullable error))completion;
  397. /** @fn sendEmailVerificationBeforeUpdatingEmail:completion:
  398. @brief Send an email to verify the ownership of the account then update to the new email.
  399. @param email The email to be updated to.
  400. @param actionCodeSettings An `FIRActionCodeSettings` object containing settings related to
  401. handling action codes.
  402. @param completion Optionally; the block invoked when the request to send the verification
  403. email is complete, or fails.
  404. */
  405. - (void)sendEmailVerificationBeforeUpdatingEmail:(nonnull NSString *)email
  406. actionCodeSettings:(nonnull FIRActionCodeSettings *)actionCodeSettings
  407. completion:
  408. (nullable void (^)(NSError *_Nullable error))completion;
  409. @end
  410. /** @class FIRUserProfileChangeRequest
  411. @brief Represents an object capable of updating a user's profile data.
  412. @remarks Properties are marked as being part of a profile update when they are set. Setting a
  413. property value to nil is not the same as leaving the property unassigned.
  414. */
  415. NS_SWIFT_NAME(UserProfileChangeRequest)
  416. @interface FIRUserProfileChangeRequest : NSObject
  417. /** @fn init
  418. @brief Please use `FIRUser.profileChangeRequest`
  419. */
  420. - (instancetype)init NS_UNAVAILABLE;
  421. /** @property displayName
  422. @brief The user's display name.
  423. @remarks It is an error to set this property after calling
  424. `FIRUserProfileChangeRequest.commitChangesWithCallback:`
  425. */
  426. @property(nonatomic, copy, nullable) NSString *displayName;
  427. /** @property photoURL
  428. @brief The user's photo URL.
  429. @remarks It is an error to set this property after calling
  430. `FIRUserProfileChangeRequest.commitChangesWithCallback:`
  431. */
  432. @property(nonatomic, copy, nullable) NSURL *photoURL;
  433. /** @fn commitChangesWithCompletion:
  434. @brief Commits any pending changes.
  435. @remarks This method should only be called once. Once called, property values should not be
  436. changed.
  437. @param completion Optionally; the block invoked when the user profile change has been applied.
  438. Invoked asynchronously on the main thread in the future.
  439. */
  440. - (void)commitChangesWithCompletion:(nullable void (^)(NSError *_Nullable error))completion;
  441. @end
  442. NS_ASSUME_NONNULL_END