FIRUser.h 27 KB

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